[R] data analysis. R
so i am having this question what should i do if the give data file (.txt) has 4 columns, but different lengths? how can i read them in R? any idea for the following problem? Gas consumption (1000 cubic feet) was measured before and after insulation was put into a house. We are interested in looking at the effect of insulation on gas consumption. The average outside temperature (degrees celcius) was also measured. The data are included in the file "insulation.txt". (a) Determine if insulation in the house effects the average gas consumption. (b) How much extra gas is used when there is no insulation? Provide an interval estimate as well as a point estimate. heres the content in "insulation.txt" (u can just copy and paste it to the notepad so can be read in R) Before insulAfter insul. tempgas tempgas -0.87.2-0.74.8 -0.76.90.84.6 0.46.41.04.7 2.56.01.44.0 2.95.81.54.2 3.25.81.64.2 3.65.62.34.1 3.94.72.54.0 4.25.82.53.5 4.35.23.13.2 5.44.93.93.9 6.04.94.03.5 6.04.34.03.7 6.04.44.23.5 6.24.54.33.5 6.34.64.63.7 6.93.74.73.5 7.03.94.93.4 7.44.24.93.7 7.54.04.94.0 7.53.95.03.6 7.63.55.33.7 8.04.06.22.8 8.53.67.13.0 9.13.17.22.8 10.2 2.67.52.6 8.02.7 8.72.8 8.81.3 9.71.5 thx and any ideas would help. -- View this message in context: http://www.nabble.com/data-analysis.-R-tp22641912p22641912.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] data analysis. R
thx for ur fast responds. but sorry for asking stupid, i am a turn beginner of R (just trying it out <3 months, and i am taking my first course about it) so, to tackle this questions, i was told to use "nested design" method, could you actually show me how would u attempt this problem? (a) Determine if insulation in the house effects the average gas consumption. (b) How much extra gas is used when there is no insulation? Provide an interval estimate as well as a point estimate. i just got confused by the backgroud information. "We are interested in looking at the effect of insulation on gas consumption. The average outside temperature (degrees celcius) was also measured." so how should my model looks like? i dont even know what should be my explanatory/response variables... thx in advance Gabor Grothendieck wrote: > > This works with the example. If the real data is different it may not > work. To run the example below just copy and paste it into R. > To run with the real data replace textConnection(Lines) with > "insulation.txt" everywhere. > > Lines <- "Before insulAfter insul. > tempgas tempgas > -0.87.2-0.74.8 > -0.76.90.84.6 > 0.46.41.04.7 > 2.56.01.44.0 > 2.95.81.54.2 > 3.25.81.64.2 > 3.65.62.34.1 > 3.94.72.54.0 > 4.25.82.53.5 > 4.35.23.13.2 > 5.44.93.93.9 > 6.04.94.03.5 > 6.04.34.03.7 > 6.04.44.23.5 > 6.24.54.33.5 > 6.34.64.63.7 > 6.93.74.73.5 > 7.03.94.93.4 > 7.44.24.93.7 > 7.54.04.94.0 > 7.53.95.03.6 > 7.63.55.33.7 > 8.04.06.22.8 > 8.53.67.13.0 > 9.13.17.22.8 > 10.2 2.67.52.6 >8.02.7 >8.72.8 >8.81.3 >9.71.5" > > nfld <- count.fields(textConnection(Lines)) > data.lines <- readLines(textConnection(Lines)) > data.lines <- ifelse(nfld == 2, paste("NA NA", data.lines), data.lines) > my.data <- read.table(textConnection(data.lines), header = TRUE, skip = 1) > > > > > On Sat, Mar 21, 2009 at 8:13 PM, UBC wrote: >> >> so i am having this question >> what should i do if the give data file (.txt) has 4 columns, but >> different >> lengths? >> how can i read them in R? >> any idea for the following problem? >> >> >> Gas consumption (1000 cubic feet) was measured before and after >> insulation >> was put into >> a house. We are interested in looking at the effect of insulation on gas >> consumption. The >> average outside temperature (degrees celcius) was also measured. The data >> are included in >> the file "insulation.txt". >> >> (a) Determine if insulation in the house effects the average gas >> consumption. >> (b) How much extra gas is used when there is no insulation? Provide an >> interval estimate >> as well as a point estimate. >> >> heres the content in "insulation.txt" (u can just copy and paste it to >> the >> notepad so can be read in R) >> >> Before insul After insul. >> temp gas temp gas >> -0.8 7.2 -0.7 4.8 >> -0.7 6.9 0.8 4.6 >> 0.4 6.4 1.0 4.7 >> 2.5 6.0 1.4 4.0 >> 2.9 5.8 1.5 4.2 >> 3.2 5.8 1.6 4.2 >> 3.6 5.6 2.3 4.1 >> 3.9 4.7 2.5 4.0 >> 4.2 5.8 2.5 3.5 >> 4.3 5.2 3.1 3.2 >> 5.4 4.9 3.9 3.9 >> 6.0 4.9 4.0 3.5 >> 6.0 4.3 4.0 3.7 >> 6.0 4.4 4.2 3.5 >> 6.2 4.5 4.3 3.5 >> 6.3 4.6 4.6 3.7 >> 6.9 3.7 4.7 3.5 >> 7.0 3.9 4.9 3.4 >> 7.4 4.2 4.9 3.7 >> 7.5 4.0 4.9 4.0 >> 7.5 3.9 5.0 3.6 >> 7.6 3.5 5.3 3.7 >> 8.0 4.0 6.2 2.8 >> 8.5 3.6 7.1 3.0 >> 9.1 3.1 7.2 2.8 >> 10.2 2.6 7.5 2.6 >> 8.0 2.7 >> 8.7 2.8 >> 8.8 1.3 >> 9.7 1.5 >> >> >> >> thx and any ideas would help. >> -- >> View this message in context: >> http://www.nabble.com/data-analysis.-R-tp22641912p22641912.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> R-help@r-project.org maili
[R] Any package to produce QQplot for survival model checking?
Hi there! S provide some functions, such as "qq.weibull", to produce various qqplot for model checking. But I can't find the corresponding version in R. Does any R package available to produce these qqplots? Many thanks in advance!! Cheers~~~ Popo [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] Any package to produce QQplot for survival model checking?
Hi, Steve! Thanks for reply! Acutally, that's what I thought too. But I believe some special control terms are needed. Do you know how could I find some examples? Thanks again. Popo 2009/7/16 Steve Lianoglou > Hi, > > > On Jul 16, 2009, at 2:03 PM, popo UBC wrote: > > Hi there! >> >> S provide some functions, such as "qq.weibull", to produce various qqplot >> for model checking. But I can't find the corresponding version in R. Does >> any R package available to produce these qqplots? >> >> Many thanks in advance!! >> > > > Perhaps: ?qqplot > > -- > Steve Lianoglou > Graduate Student: Physiology, Biophysics and Systems Biology > Weill Medical College of Cornell University > > Contact Info: http://cbio.mskcc.org/~lianos/contact > > > > [[alternative HTML version deleted]] __ R-help@r-project.org 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.
[R] About the efficiency of R optimization function
Hi all! The objective function I want to minimize contains about 10 to 20 variables, maybe more in the future. I never solved such problems in R, so I had no idea about the efficiency of R's optimization functions. I know doing loop in R is quite slow, so I am not sure whether this shortage influences the speed of R's optimization functions. I would be very appreciated if anyone could share some experiences with me. The speed, stability of the R's optimization functions. Is it helpful to call a C/Fortran code to do the job, if possible. Many thanks in advance. Popo [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] About the efficiency of R optimization function
Hi Charlie, Thank you so much for suggestions!! Actually, I used the optimization toolbox in MABLAB before and I even wrote some numerical optimization programs by myself. As far as I know, some commercial optimization softwares had already replaced L-BFGS-B by more advanced algorithms, such as interior point method, SQP(sequential quadratic programming), implemented under trust region strategy. So, - Have you ever tried these techniques? Are they available in R already? - In your previous experieces, did R work satisfactory? I mean, was it often that R failed to converge or spent too much time? - Mainly, I need to calculate the MLE. But I really have no idea what the likelihood may looks like. According to your experiences, would the likelihood function be too complicated? Is L-BFGS-B good enough? Thanks again!! Popo 2009/5/14 cls59 > > > popo UBC wrote: > > > > Hi all! > > > > The objective function I want to minimize contains about 10 to 20 > > variables, > > maybe more in the future. I never solved such problems in R, so I had no > > idea about the efficiency of R's optimization functions. I know doing > loop > > in R is quite slow, so I am not sure whether this shortage influences the > > speed of R's optimization functions. > > > > I would be very appreciated if anyone could share some experiences with > > me. > > The speed, stability of the R's optimization functions. Is it helpful to > > call a C/Fortran code to do the job, if possible. > > > > Many thanks in advance. > > > > Popo > > > > > > > Many functions available in R are implemented using a compiled language > such as C or Fortran- not the R language it's self. For example, the > "Source" > section of the help page for optim states that the code for the > Nelder-Mead, > BFGS and Conjugate Gradient methods were translated to C from Pascal and > then further optimized. The L-BFGS-B method appears to be implemented as > Fortran code. > > Looking at the source of the optim function reveals that results are > computed by a call to .Internal(). Such calls usually indicate that R is > handing computations off to a compiled, rather than interpreted, routine. > > If you have C or Fortran code you would prefer to use, take a look at the > help pages for .C() and .Fortran() as well as the "Writing R Extensions" > manual. The command line tool R CMD SHLIB will help you compile your code > to > shared libraries that can be loaded by R using dyn.load(). > > -Charlie > > > > > - > Charlie Sharpsteen > Undergraduate > Environmental Resources Engineering > Humboldt State University > -- > View this message in context: > http://www.nabble.com/About-the-efficiency-of-R-optimization-function-tp23552061p23552668.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]] __ R-help@r-project.org 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.
[R] A problem about "nlminb"
Hello everyone! When I use "nlminb" to minimize a function with a variable of almost 200,000 dimension, I got the following error. > nlminb(start=start0, msLE2, control = list(x.tol = .001)) Error in vector("double", length) : vector size specified is too large I had the following setting options(expressions=6) options(object.size=10^15) I have no idea about what might be wrong. Any suggestion is highly appreciated!! Thanks!! popo [[alternative HTML version deleted]] __ R-help@r-project.org 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.