Skip to content

how to calcaulate matrices for two subsets

1 message · Adam D. I. Kramer

#
Hi Bill,

Tell me more about the Obs object. The "subset" of an lm should be a vector
telling the lm which observations to use...if Obs[197,396] is a single
number, only one observation will be used, and chances are your model is not
what you intended.

Also, predict(result1,newdata=Obs[397,339]) needs that cell in Obs to have a
column called "SP500 index," and predict.lm (check the man page for it) will
only return one number, the prediction for the given new data.

If you want it to have 3 numbers, maybe Obs[397:399] is what you want? The
colon means "397 through 399, inclusive" while the comma means "row 397,
column 399".  If this is your mistake, you actually want "subset=197:396,
data=Obs" in your call to lm.

Hope this helped.

--Adam
On Thu, 11 Sep 2008, Xianchun Liao wrote: