rcoder mpdotbookgmailcom hi jim thanks much reply suggestions although statement pregkcoeflmttsel_col applying lm vectors contents one vectors sel_col changing cycle outer loop mistake didnt specify information rows data go modified statement resemble something like peuuregjj1kcoeflmttsel_col j1 ensures jump 2 rows slope intercept arranged vertically op matrix tried section one column save time seemed op varying data preg want extract slope data new matrix added statement wondering neater way tell lm function op slope data perhaps one way would use jk vs jj1k regression statement forcing successive slope data overwrite cell locations containing intercept data also full code takes awfully long time run would anyone able suggest way mee speed perhaps regression algorithm thanks rcoder jholtman wrote actually read closer see problem think statement pregkcoeflmttsel_col going preg 200x100 matrix storing two values coefficients repeated 100 times column nothing wrong nested loops algorithm using might want use browser would see something like browse1 strsel_col num 15 0115 2666 0811 1440 0879 browse1 strtt timeseries 15 2 10 2 4 6 8 10 browse1 n debug allisnasel_col preg k coeflmtt sel_col browse1 n debug preg k coeflmtt sel_col browse1 k 1 1 browse1 n debug k browse1 n debug sel_col pmatwt k browse1 k 1 2 browse1 strsel_col num 15 0115 2666 0811 1440 0879 browse1 strpreg num 1200 1100 6356 0587 6356 0587 6356 browse1 strpmatwt num 15 1100 0115 2666 0811 1440 0879 browse1 coeflmttsel_col intercept sel_col 6355760 0586699 browse1 strpreg num 1200 1100 6356 0587 6356 0587 6356 browse1 would help understand happening mon aug 4 2008 835 pm jim holtman wrote exactly problem nothing wrong nested loops leading believe problem ran program seems terminate time seems spent following statement ifallisnasel_col pregkcoeflmttsel_col given appear executing statement 9000 times surprising provide details 0 512 root 1 445 coef 2 441 lm 3 157 eval 4 156 eval 5 156 modelframe 6 153 modelframedefault 7 60 sapply 8 38 lapply 9 30 fun 10 11 11 10 match 12 08 isfactor 13 07 inherits 10 10 deparseopts 11 03 pmatch 9 05 aslist 8 17 unique 9 07 uniquedefault 9 06 unlist 10 04 lapply 8 03 unlist 7 40 naomit 8 38 naomitdataframe 9 30 10 29 dataframe 11 06 duplicated 12 03 duplicateddefault 11 03 12 02 ts 11 03 mon aug 4 2008 1258 pm rcoder wrote hi guess question really nested loop construct whether intend code previous post would grateful anyone used nested loops could let know something wrong thanks rcoder rcoder wrote hi everyone im experiencing difficulty getting results want use nested loop data set perform calculations try apply regression rolling window code runs regression results getting intercept slope simply repeated results matrix regression seem obeying instructions nested loop intend calculate regression coefficients data one row time struggling code many days testing various parts seem get nested loop work want would grateful suggestions brief version code code start libraryzoo seedset1 pmatmatrixrnorm1000 nrow100 ncol100 maxcolncolpmat maxrownrowpmat startrow10 period10 wind2 roll window subdivperiodwind rollstart11 start roll period1 converting pmat ts rollapply work pmattstspmat pregmatrixnancolmaxcolnrow2maxrow pmatwtmatrixna nrowsubdivncolmaxcol mult_colmatrix15 nrow5 ncol1 rolling calculations rollstartmaxrow extract relevant timeframe dslicepmattsiperiodi dslicetstsdslice operating sliced data pminrollapplydslicets wind bywind min narmf pmaxrollapplydslicets wind bywind max narmf pmultpminpmax calculating product tttimepmult j 15 1st nested loop pmatwtjpmultjmult_colj rolling regression analysis k 1maxcol 2nd nested loop sel_colpmatwtk ifallisnasel_col pregkcoeflmttsel_col code end thanks rcoder view message context httpwwwnabblecomproblemwithnestedloopforregressiontp18792841p18815273html sent r help mailing list archive nabblecom ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code jim holtman cincinnati oh 1 513 646 9390 problem trying solve jim holtman cincinnati oh 1 513 646 9390 problem trying solve ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code view message context httpwwwnabblecomproblemwithnestedloopforregressiontp18792841p18837399html sent r help mailing list archive nabblecom ______________________________________________ rhelprprojectorg mailing list httpsstatethzchmailmanlistinforhelp please read posting guide httpwwwrprojectorgpostingguidehtml provide commented minimal selfcontained reproducible code tue 05 aug 2008 114152 0700 r problem nested loop regression