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:
I am an R beginner and trying to run a market model using event study in
R framework.
First, I run a market model, that is lm(stock security~SP500 index,
subset=Obs[197, 396]) ->result1
Then I get predict results for a new dataset using predict (result1,
newdata=Obs[397,399]) ->pred1
Pred1 should have three numbers.
Now I need to calculate abnormal return by the formula stock security
[397,399] -pred1
But it does not work after trying many times.
So, how to write a R code to implement the formula and get right
results.
Thanks,
Bill
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.