I need to have all elements of a matrix multiplied by a weight before being post-multiplied by itself, as shown in the forst block of codes below. I can also multiply the matrix by the square root of the weight and then take the outer product. Actually, what I need is this. Denote each row of the matrix by a row vector as xi and each element of the weighting vector as wi. Then, I need the sum of wi * t(xi) %*% xi over i. Any suggestion for a compact approach would be appreciated. set.seed(76543211) w<-1:10; w a<-matrix(rpois(20,2),nrow=10); a b<-a a<-w*a t(a)%*%b set.seed(76543211) a<-matrix(rpois(20,2),nrow=10); a a<-sqrt(w)*a; a t(a)%*%a On 1/4/2017 5:41 PM, Steven Yen wrote:> I need help with gls{nlme}. > Specifically, I am estimating an equation with AR(1) using > maximum-likelihood. I am not understanding the correlationoption > below. Help appreciated. > > ==> library(nlme) > eq1<-log(chnimp)~log(chempi)+log(gas)+log(rtwex)+befile6+ > affile6+afdec6 > reg1<-gls(eq1,data=mydata,correlation=corAR1(),method="ML",verbose=T) >[[alternative HTML version deleted]]
Is this a question? You seem to have three possible calculations, have already implemented two of them (?) and it is unclear (to me) what you think the right answer for any of them is supposed to be. -- Sent from my phone. Please excuse my brevity. On June 7, 2017 8:50:55 PM PDT, Steven Yen <syen04 at gmail.com> wrote:>I need to have all elements of a matrix multiplied by a weight before >being post-multiplied by itself, as shown in the forst block of codes >below. I can also multiply the matrix by the square root of the weight >and then take the outer product. > >Actually, what I need is this. Denote each row of the matrix by a row >vector as xi and each element of the weighting vector as wi. Then, I >need the sum of wi * t(xi) %*% xi over i. > >Any suggestion for a compact approach would be appreciated. > >set.seed(76543211) >w<-1:10; w >a<-matrix(rpois(20,2),nrow=10); a >b<-a >a<-w*a >t(a)%*%b > >set.seed(76543211) >a<-matrix(rpois(20,2),nrow=10); a >a<-sqrt(w)*a; a >t(a)%*%a > > > > >On 1/4/2017 5:41 PM, Steven Yen wrote: >> I need help with gls{nlme}. >> Specifically, I am estimating an equation with AR(1) using >> maximum-likelihood. I am not understanding the correlationoption >> below. Help appreciated. >> >> ==>> library(nlme) >> eq1<-log(chnimp)~log(chempi)+log(gas)+log(rtwex)+befile6+ >> affile6+afdec6 >> reg1<-gls(eq1,data=mydata,correlation=corAR1(),method="ML",verbose=T) >> > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
OK Thanks. Your response made me think. Here (the last line) is what I need: set.seed(76543211) w<-1:10; w a<-matrix(rpois(20,2),nrow=10); a t(w*a)%*%a On 6/8/2017 12:09 PM, Jeff Newmiller wrote:> Is this a question? You seem to have three possible calculations, have already implemented two of them (?) and it is unclear (to me) what you think the right answer for any of them is supposed to be. > -- Sent from my phone. Please excuse my brevity. On June 7, 2017 > 8:50:55 PM PDT, Steven Yen <syen04 at gmail.com> wrote: >> I need to have all elements of a matrix multiplied by a weight before >> being post-multiplied by itself, as shown in the forst block of codes >> below. I can also multiply the matrix by the square root of the weight >> and then take the outer product. >> >> Actually, what I need is this. Denote each row of the matrix by a row >> vector as xi and each element of the weighting vector as wi. Then, I >> need the sum of wi * t(xi) %*% xi over i. >> >> Any suggestion for a compact approach would be appreciated. >> >> set.seed(76543211) >> w<-1:10; w >> a<-matrix(rpois(20,2),nrow=10); a >> b<-a >> a<-w*a >> t(a)%*%b >> >> set.seed(76543211) >> a<-matrix(rpois(20,2),nrow=10); a >> a<-sqrt(w)*a; a >> t(a)%*%a[[alternative HTML version deleted]]
I am running R-3.0.3 on RStudio 1.1.183. I have recently gotten the following error message while saving an .RData file with the save.image command. I have not had this problem until recently. Help appreciated. ==Error in save.image("bope1a.RData") : image could not be renamed and is left in bope1a.RDataTmp [[alternative HTML version deleted]]
Google is your friend (e.g. [1]). Gist of story is that that an existing file of that name is being "protected" by the operating system and you need to use filesystem utilities or reboot your machine to release the existing file from this condition. [1] https://stat.ethz.ch/pipermail/r-help/2002-April/020169.html -- Sent from my phone. Please excuse my brevity. On January 26, 2018 12:27:55 AM PST, Steven Yen <syen04 at gmail.com> wrote:>I am running R-3.0.3 on RStudio 1.1.183. I have recently gotten the >following error message while saving an .RData file with the save.image >command. I have not had this problem until recently. Help appreciated. > >==>Error in save.image("bope1a.RData") : > image could not be renamed and is left in bope1a.RDataTmp > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
I build binary data files into a library by placing the .rda files at the proper \data sub-folder before building the library with the following procedure: 1. File -> Open project 2. Build -> Build binary packages. This has worked up to 3 .rda files. Now, I add another .rda file to the folder. I received a very strange, seemingly unrelated warning message that says: Warning: object '.Random.seed' is created by more than one data call The weird thing about this is, repeating the procedure, I sometime can access the data file from the library (i.e., by data(filename)), other time I cannot access the data file. The data file is big but not so big (571 KB). Any clues? Why am I getting that warning message? =Below is a log with more details. ==> Rcmd.exe INSTALL --build --preclean yenlib3 * installing to library 'C:/Users/syen01/Documents/R/win-library/3.4' * installing *source* package 'yenlib3' ... ** R ** data *** moving datasets to lazyload DB Warning: object '.Random.seed' is created by more than one data call ** preparing package for lazy loading ** help *** installing help indices converting help for package 'yenlib3' finding HTML links ... done aids html all.variables html (truncated) ate.boprobitE html ** building package indices ** testing if installed package can be loaded *** arch - i386 *** arch - x64 * MD5 sums packaged installation of 'yenlib3' as yenlib3_1.1.0.zip * DONE (yenlib3) In R CMD INSTALL Binary package written to Y:/ [[alternative HTML version deleted]]