Sorry, I'm weird in English and hope you understand my words.
Set my data as follows.
Year, Week, A017670, A030200, A32640, Market, Ind. 2000, 2000-01, 0.02, -0.001, 0.005, 0.007, 0.004, 2000, 2000-2002 ... 2000, 2000-52 2001, 2001-01 ... 2014, 2014-52
I adjust R-squared
and SSE
from my retrograde model
.
And I want to write (save) R-squared
with SSE
.
My models are:
LM (A017670 ~ Market + IND.20, subset = (year = 2000)) LM (A017670 ~ Market + Ind. 20, Subset = (year = 2001)) ... LM (A017670 ~ market + in 20, subset = (year = 2014)) LM (A030200 ~ market + IND.20, subset = (year = 2000)) LM (A030200) ~ Market + India 20, Subset = (Year = 2001)) ... LM (A030200 ~ Bazaar + India20, Subset = (Year = 2014)) LM (A032640 ~ Bazaar + Ind 20, Subset = (Year = 2000) ) LM (A032640 ~ Bazaar + Ind 20, Subset = (Year = 2001)) ... LM (A032640 ~ Market + Indus 20, Subset = (Year = 2014))
I need to adjust each model R-squared
and SSE
.
My data is 15 years of data for 700 companies (A017670, A030200, A032640, ...........)
, I have to run regression 10,500 times.
It is very boring.
In addition, IND.20
stands for industrial production. Industrial average 30 are the branches. (Ind 20, Ind 21, Ind 22, ............. Indeed 4)
Thanks
< Div class = "post-text" itemprop = "text">
Create combinations of companies and years:
models < - ("Company", "year"), (extended grid (name (df1) [grep ("^ a", name (df1)), unique (df 1 $ year) StringsFactors = F) Code> call LM
on each combination:
do.call (rbind, lapply (seq_len (nrow (model) ), FUN = function (i) {formula1 & lt; - sprintf ("% s ~ market + ind 20", model $ company [i]) Fit 1 & lt; - LM (formula = formula1, data = df 1 [df 1 $ year == model $ year [i],]) sfit & lt; - summary (fit1) data.frame (year = model $ year [i], company = model $ company [i], ed Ararsk = Saftia $ adj.r.squared, SSE = Deweyan fit (1))}))
No comments:
Post a Comment