Skip to content
Back to formatted view

Raw Message

Message-ID: <4D09C198-87D8-4F5B-8E32-CECA35C15F37@gmail.com>
Date: 2017-02-04T16:43:11Z
From: Peter Dalgaard
Subject: Change (merge) vector by row names.
In-Reply-To: <CAKY_brEbJcey__MpJ9jjyUPLt6_yG25poRVbQC9mdfjr-S22Yw@mail.gmail.com>

> On 03 Feb 2017, at 21:07 , Art U <art.tem.us at gmail.com> wrote:
> 
> Hello,
> 
> I have a vector of coefficients from backward selection model that looks
> like:
> 
>             [,1]
> (Intercept) -0.15
> s1[, 1]      2.65
> s1[, 2]      1.81
> s1[, 5]      2.35
> 
> 
> I'd like to get a new vector that contains zeroes for variables that were
> not included in the final model. For example here it suppose to be:
> 
>             [,1]
> (Intercept) -0.15
> s1[, 1]      2.65
> s1[, 2]      1.81
> s1[, 3]      0
> s1[, 4]      0
> s1[, 5]      2.35
> 
> s1[, 6]      0
> 
> s1[, 7]      0
> 
> s1[, 8]      0
> 
> 
> Is there simple function I can use to get such result?

I wouldn't waste time looking for it... It goes something like

fullnames <- ...
extended <- matrix(0,length(fullnames),1)
rownames(extended) <- fullnames
extended[rownames(reduced),] <- reduced

where, presumably, you can find fullnames fromm the fit of a full model.

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com