[R] Residual resampling for non linear reg model
I was attempting to use the residual resampling approach to generate 999 bootstrap samples of alpha and beta and find their confidence intervals. However, I keep getting the error message:Error in nls(resample.mp ~ cases/(alpha + (beta * cases)), start = init.values, : singular gradientafter R has only produced a few bootstraps.Could anyone suggest where I am going wrong? Would greatly appreciate it!Mary manpower<-read.table("http://www.creem.st-and.ac.uk/len/classes/mt3607/data/manhours_surgical.dat";, header=TRUE)#attach dataattach(manpower)B<-999#number of data pointsn<-dim(manpower)[1]#alpha level to use for the confidence limitsalpha<-0.05#matrix that's going to contain the bootstrap coefficientsboot.coef<-matrix(NA, B+1, 2)#fit the initial modelinit.values<-c(alpha=20,beta=0)model<-nls(manhours~cases/(alpha+(beta*cases)), start=init.values, trace=TRUE)pred<-predict(model)resid<-resid(model)#do the bootstrapfor (i in 1:B){ #resample the residuals resample.ind! ex<-sample(1:n,n,replace=T) resample.mp<-pred+resid[resample.index] #refit the model init.values<-c(alpha=20,beta=0) new.model<-nls(resample.mp~cases/(alpha+(beta*cases)),start=init.values, trace=TRUE) #extract the parameter estimates boot.coef[i,]<-coef(new.model)}#add the original parameter estimates boot.coef[B+1,]<-coef(model)#calculate confidence intervalsfor(i in 1:2){ ci<-quantile(boot.coef[,i],probs=c(alpha/2,(1-alpha/2))) cat("residual bootstrap confidence intervals for parameter",i,"are",ci,"\n")} Miss your Messenger buddies when on-the-go? Get Messenger on your Mobile! _ Win Indiana Jones prizes with Live Search [[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] Residual resampling for non linear reg model
Since sending this message I have now solved the problem - needed to alter the initial values of alpha and beta! > From: [EMAIL PROTECTED]> To: r-help@r-project.org> Date: Mon, 5 May 2008 > 00:03:53 +0100> Subject: [R] Residual resampling for non linear reg model> > > > > > I was attempting to use the residual resampling approach to generate > 999 bootstrap samples of alpha and beta and find their confidence intervals. > However, I keep getting the error message:Error in nls(resample.mp ~ > cases/(alpha + (beta * cases)), start = init.values, : singular gradientafter > R has only produced a few bootstraps.Could anyone suggest where I am going > wrong? Would greatly appreciate it!Mary > manpower<-read.table("http://www.creem.st-and.ac.uk/len/classes/mt3607/data/manhours_surgical.dat";, > header=TRUE)#attach dataattach(manpower)B<-999#number of data > pointsn<-dim(manpower)[1]#alpha level to use for the confidence > limitsalpha<-0.05#matrix that's going to contain the bootstrap > coefficientsboot.coef<-matrix(NA, B+1, 2)#fit the initial > modelinit.values<-c(alpha=20,beta=0)model<-nls(manhours~cases/(alpha+! (beta*cases)), start=init.values, trace=TRUE)pred<-predict(model)resid<-resid(model)#do the bootstrapfor (i in 1:B){ #resample the residuals resample.ind!> ex<-sample(1:n,n,replace=T) resample.mp<-pred+resid[resample.index] #refit the model init.values<-c(alpha=20,beta=0) new.model<-nls(resample.mp~cases/(alpha+(beta*cases)),start=init.values, trace=TRUE) #extract the parameter estimates boot.coef[i,]<-coef(new.model)}#add the original parameter estimates boot.coef[B+1,]<-coef(model)#calculate confidence intervalsfor(i in 1:2){ ci<-quantile(boot.coef[,i],probs=c(alpha/2,(1-alpha/2))) cat("residual bootstrap confidence intervals for parameter",i,"are",ci,"\n")}> > Miss your Messenger buddies when on-the-go? Get Messenger on your Mobile! > _> Win Indiana Jones prizes with Live Search> > [[alternative HTML version deleted]]> > __> R-help@r-project.org mailing list> https! ://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting gu ide 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] R version of SAS Proc Varclus
I am interested in finding an R version of SAS "Proc Varclus". SAS's Proc Varclus implements an oblique cluster analysis based on principal components. How can I find out if R has a package that runs the same algorithm implemented in SAS "Proc Varclus"? Thank you, Mary Helen Black Mary Helen Black, M.S. Keck School of Medicine of USC Department of Preventive Medicine Division of Biostatistics Phone: 323-442-3073 (office) E-mail: [EMAIL PROTECTED] __ 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] R version of SAS Proc Varclus
I am interested in finding an R version of SAS "Proc Varclus". SAS's Proc Varclus implements an oblique cluster analysis based on principal components. How can I find out if R has a package that runs the same algorithm implemented in SAS "Proc Varclus"? Thank you, Mary Helen Black __ Mary Helen Black, M.S. Keck School of Medicine of USC Department of Preventive Medicine Division of Biostatistics Phone: 323-442-3073 (office) E-mail: [EMAIL PROTECTED] __ 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] rmultinomial() function
After scouring the online R resources and help pages, I still need clarification on the function rmultinomial(). I would like to create a vector, say of 100 elements, where every element in the vector can take on the value of 0, 1 or 2, and where each of those values have a specific probability. ie. the probability a given element in the vector = 0 is 0.06, 1 = 0.38, 2 = 0.56 (probabilities sum to 1). Can I use rmultinomial() function to do this? The following code does not seem to produce the result I need, but this sort of code is all I could find the R "help" pages: > rmultinomial(100,c(0.06,0.38,0.56)) [1] 3 29 68 > rmultinomial(100,c(0.06,0.38,0.56),long=TRUE) [1] 3 3 2 2 3 2 3 3 2 3 2 3 3 3 2 2 3 3 2 3 1 2 3 3 3 3 3 3 2 3 3 2 3 3 3 2 3 2 2 3 2 3 2 3 3 3 2 1 3 3 1 [52] 2 3 2 2 3 3 2 2 2 1 3 3 2 3 3 3 3 2 3 3 3 3 2 3 2 3 3 2 3 3 2 3 3 2 3 2 3 3 2 3 3 3 2 3 2 2 2 2 2 Also, I don't really understand the difference between the default long=FALSE and long=TRUE. The R "help" simply states that you use "long TRUE to choose one generator, FALSE to choose another one"; however I could not find any documentation that described what the difference between those generators is. Any clarification would be greatly appreciated! Thanks, Mary __ 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] [PS] rmultinomial() function
Thanks Ben and Eric. I've already tried rmultinom(), and there is a rmultinomial() function as well (which is in the multinomRob package). The rmultinomial() is supposed to be a random number generator for the multinomial distribution. There is an argument "long" which if set to TRUE or FALSE, utlize different generators, but the documentation doesn't explain any further. Thus, my confusion about the output. If anyone can explain further how the two generators are different, I would love to know! - Original Message - From: Ben Fairbank <[EMAIL PROTECTED]> Date: Wednesday, March 19, 2008 7:36 am Subject: RE: [PS] [R] rmultinomial() function To: Mary Black <[EMAIL PROTECTED]>, r-help@r-project.org > Mary -- > > The dmultinomial function (try ?Multinomial, noting that it is an > uppercase M) has a "log" option, which, if set to TRUE, returns > logarithms of > probabilities, but that is for computing probabilities, not generating > samples. Perhaps the "long" you referred to is a misprint for "log?" > > In any case, try ?Multinomial, and give rmultinom() another try. > Note,however, that its output gives the _number_ of each of the > sampled items > produced in a single sample, not the sequence of draws. If you > need the > sequence, then I think that the reply from Erik Iverson tells you how > best to proceed. > > Ben > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org]On Behalf Of Mary Black > Sent: Tuesday, March 18, 2008 5:29 PM > To: r-help@r-project.org > Subject: [PS] [R] rmultinomial() function > > After scouring the online R resources and help pages, I still need > clarification on the function rmultinomial(). I would like to > create a > vector, say of 100 elements, where every element in the vector can > takeon the value of 0, 1 or 2, and where each of those values have a > specific probability. ie. the probability a given element in the > vector= 0 is 0.06, 1 = 0.38, 2 = 0.56 (probabilities sum to 1). > Can I use > rmultinomial() function to do this? > > The following code does not seem to produce the result I need, but > thissort of code is all I could find the R "help" pages: > > > rmultinomial(100,c(0.06,0.38,0.56)) > [1] 3 29 68 > > rmultinomial(100,c(0.06,0.38,0.56),long=TRUE) > [1] 3 3 2 2 3 2 3 3 2 3 2 3 3 3 2 2 3 3 2 3 1 2 3 3 3 3 3 3 2 3 > 3 2 3 > 3 3 2 3 2 2 3 2 3 2 3 3 3 2 1 3 3 1 > [52] 2 3 2 2 3 3 2 2 2 1 3 3 2 3 3 3 3 2 3 3 3 3 2 3 2 3 3 2 3 3 > 2 3 3 > 2 3 2 3 3 2 3 3 3 2 3 2 2 2 2 2 > > Also, I don't really understand the difference between the default > long=FALSE and long=TRUE. The R "help" simply states that you use > "longTRUE to choose one generator, FALSE to choose another one"; > however I > could not find any documentation that described what the difference > between those generators is. Any clarification would be greatly > appreciated! > > Thanks, > > Mary > > __ > 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-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] read sas data into R
Hi I am having trouble using read.ssd. Can someone help? The code that I have written is *sashome<-"C:/Mary/Datasets"* *read.ssd(read.ssd(file.path(sashome, "core", "sashelp"), "surv_1v",* *sascmd = file.path(sashome, "sas.exe"))* Here the path that I have given is correct, where the dataset surv_1v.sas7bdat is kept. The message that R gives me is this: *SAS failed. SAS program at C:\DOCUME~1\Royerm02\LOCALS~1\Temp\Rtmpdi2Osb\file4ff053f7.sas The log file will be file4ff053f7.log in the current directory NULL Warning messages: 1: "C:/Mary/Datasets /sas.exe" not found in: system(paste(sascmd, tmpProg)) 2: SAS return code was -1 in: read.ssd(file.path("C:/Mary/Datasets", > * what do I do? The help for read.ssd does not help either. So any help will be greatly appreciated. Mary [[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] extract year or month from date
Hi, I am having trouble extracting just the year or the month or the day from a date such as 5/7/2007 which is May 7th 2007. Is there any particular function to extract just the year from this format? When I am reading this data from a text file it is reading it correctly in the same format but does not acknowlede it as date but as a factor. If I try as.date(5/7/2007) then it is converting it to 1Jan1960. Weird it is. Any help on that front? Any help is greatly appreciated. [[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] Frequency table to histogram
I have read a frequency table in to R called "temp." I now want to create a histogram table from it, but I obviously first have to expand the data - to the sample size of 100. I want to use the command rep(), but I'm not sure how to go about it..I tried using the code: temp1<-rep(temp$Chest,100) hist(temp1) But this creates a v. odd histogram so I know it must be wrong! Would be very grateful if any one could help me out! Mary _ [[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] Frequency table to histogram
Hi, Sorry, yes that would be a better idea, Luc! Here are the first few lines of the frequency table.. Count Chest 1 333 2 1834 3 8135 418536 542037 In my previous email I said the sample size was 100, I just meant that as an example, obviously it's far greater than that.. Louisa > Date: Tue, 7 Apr 2009 10:00:55 -0400 > From: villa...@dms.umontreal.ca > To: statsstud...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] Frequency table to histogram > > Hi Mary, > > Could you please provide a copy of the first few lines of your frequency > table (with only relevant columns)? I think this could help many > potential contributors understand in more details what you're trying to do. > > Cheers, > > Luc > > Mary Winter wrote: > > > > > > I have read a frequency table in to R called "temp." I now want to create a > > histogram table from it, but I obviously first have to expand the data - to > > the sample size of 100. I want to use the command rep(), but I'm not sure > > how to go about it..I tried using the code: > > > > > > > > temp1<-rep(temp$Chest,100) > > > > hist(temp1) > > > > > > > > But this creates a v. odd histogram so I know it must be wrong! > > > > > > > > Would be very grateful if any one could help me out! > > > > > > > > Mary > > > > _ > > > > > > [[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. > > _ [[elided Hotmail spam]] [[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] (no subject)
Hi, Is it possible to increase just the text size of the main title on my graph? If so, how?! Along the same lines..along the x axis at a lot of the labels overlap each other, is it possible to make this text smaller of write it on two lines so it doesn't take up as much space along the x axis? Any help would be much appreciated! Mary _ [[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] Generalised Rejection Sampling
Hi, I am trying to figure out the observed acceptance rate and M, using generalised rejection sampling to generate a sample from the posterior distribution for p. I have been told my code doesn't work because I need to "take the log of the expression for M, evaluate it and then exponentiate the result." This is because R is unable to calculate high powers such as 545.501. As you can see in my code I have tried to taking the log of M and then the exponential of the result, but I clearly must be doing something wrong. I keep getting the error message: Error in if (U <= ratio/exp(M)) { : missing value where TRUE/FALSE needed Any ideas how I go about correctly taking the log and then the exponential? rvonmises.norm <- function(n,alpha,beta) { out <- rep(0,n) counter <- 0 total.sim <- 0 p<-alpha/(alpha+beta) M <-logalpha-1)^(alpha-1))*((beta-1)^(beta-1)))/((beta+alpha-2)^(alpha+beta-2))) while(counter < n) { total.sim <- total.sim+1 proposal <- runif(1) if(proposal >= 0 & proposal <= 1) { U <- runif(1) ratio<- (p^(alpha-1))*((1-p)^(beta-1)) if(U <=ratio/exp(M)) { counter <- counter+1 out[counter] <- proposal } } } obs.acc.rate <- n/total.sim return(out,obs.acc.rate,M) } set.seed(220) temp <- rvonmises.norm(1,439.544,545.501) print(temp$obs.acc.rate) Louisa _ [[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] "taking the log then later exponentiate the result" query
Hi, I am trying to figure out the observed acceptance rate and M, using generalised rejection sampling to generate a sample from the posterior distribution for p. I have been told my code doesn't work because I need to "take the log of the expression for M, evaluate it and then exponentiate the result." This is because R is unable to calculate high powers such as 545.501. As you can see in my code I have tried to taking the log of M and then the exponential of the result, but I clearly must be doing something wrong. I keep getting the error message: Error in if (U <= ratio/exp(M)) { : missing value where TRUE/FALSE needed Any ideas how I go about correctly taking the log and then the exponential? rvonmises.norm <- function(n,alpha,beta) { out <- rep(0,n) counter <- 0 total.sim <- 0 p<-alpha/(alpha+beta) M <-logalpha-1)^(alpha-1))*((beta-1)^(beta-1)))/((beta+alpha-2)^(alpha+beta-2))) while(counter < n) { total.sim <- total.sim+1 proposal <- runif(1) if(proposal >= 0 & proposal <= 1) { U <- runif(1) ratio<- (p^(alpha-1))*((1-p)^(beta-1)) if(U <=ratio/exp(M)) { counter <- counter+1 out[counter] <- proposal } } } obs.acc.rate <- n/total.sim return(out,obs.acc.rate,M) } set.seed(220) temp <- rvonmises.norm(1,439.544,545.501) print(temp$obs.acc.rate) Louisa Get the New Internet Explore 8 Optimised for MSN. Download Now _ [[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] randomForest question--problem with ntree
Hi, I would like to use a random Forest model to get an idea about which variables from a dataset may have some prognostic significance in a smallish study. The default for the number of trees seems to be 500. I tried changing the default to ntree=2000 or ntree=200 and the results appear identical. Have changed mtry from mtry=5 to mtry=6 successfully. Have seen same problem on both a Windows machine and our linux system running 2.8 and 2.9. Sample code follws. Thanks in advance for help. Mary > m1<-as.formula(paste("as.factor(EAD)~", paste(names(clin_b)[c(5,7,10:36 )], > collapse="+"))) > m1 as.factor(EAD) ~ R_AGE + R_BMI + ASCITES...1L. + EOTAXIN + GM.CSF + IFNa + IL.10 + IL.12.p40.p70 + IL.13 + IL.15 + IL.17 + IL.2 + IL.4 + IL.5 + IL.6 + IL.7 + IL.8 + IL1.RA + IL2.R + IP.10 + MCP.1 + MIG + MIP.1a + MIP.1b + RANTES + TNFa + Male + diagnosis + race > > > > > set.seed(12345) > rF.bsl<-randomForest(m1, data=clin_b, na.action=na.omit, mtry=6, n.tree=2000) > rF.bsl$ntree [1] 500 > rF.bsl$mtry [1] 6 > print(rF.bsl) Call: randomForest(formula = m1, data = clin_b, mtry = 6, n.tree = 2000, na.action = na.omit) Type of random forest: classification Number of trees: 500 No. of variables tried at each split: 6 OOB estimate of error rate: 39.66% Confusion matrix: 0 1 class.error 0 27 7 0.2058824 1 16 8 0.667 > > > set.seed(12345) > rF.bsl<-randomForest(m1, data=clin_b, na.action=na.omit, mtry=6, n.tree=100) > rF.bsl$ntree [1] 500 > rF.bsl$mtry [1] 6 > print(rF.bsl) Call: randomForest(formula = m1, data = clin_b, mtry = 6, n.tree = 100, na.action = na.omit) Type of random forest: classification Number of trees: 500 No. of variables tried at each split: 6 OOB estimate of error rate: 39.66% Confusion matrix: 0 1 class.error 0 27 7 0.2058824 1 16 8 0.667 > > __ 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] R code -column headings
Hello, I have been noticing that some of my column headings are missing. Can you give me a clue as to how to 1] replace Var1 and Var 2 by Region and type ie do it right the first time x<-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4) rownames(x)=c( "Northeast", "Midwest", "South", "West" ) colnames(x)=c("Public", "Private") as.data.frame(as.table(x)) 2] add a column heading for region when I use addmargins(x) addmargins(x) #margin.table(x,1) #margin.table(x,2) Thank you. Sincerely, Mary A. Marion __ 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] print of objects in R
Hello, I have been watching my output as I create functions and do other things in r. One thing I don't like is the [1,] type notation at the beginning of a line. I have been able to change that to a number such as 1 2 etc. using as.data.frame(object). How can I stop the printing of a line number and column heading if I want to? I am thinking about publishing and writing of papers. It is much easier to not have to remove that leading line number when inserting output into papers. Thank you. Sincerely, mmstat __ 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] naming of columns in R dataframe consisting of mixed data (alphanumeric and numeric)
Hello, I have an r function that creates the following dataframe tresults2. Notice that column 1 does not have a column heading. Tresults2: [,1] estparam 18.0 nullval 20.0 . . . ciWidth 2.04622 HalfInterval 1.02311 pertinent code: results<-cbind( estparam, nullval, t, pv_left, pv_right, pv_two_t, estse, df, cc, tbox, llim, ulim, ciWidth, HalfInterval) tresults<-round((results),5) tresults2<-data.frame(t(tresults)) names(tresults2)<-c("Statistic ", "Value") tresults2 === After transposing my dataframe tresults2 consists of 2 columns. Col1=alphanumeric data (this really is a variable name) and col2=numeric data (this is value of varaiable). how do I name columns when columns are different (alphanumeric and numeric) to avoid the following error: Error in names(tresults2) <- c("Statistic ", "Value") : 'names' attribute [2] must be the same length as the vector [1] Am I to use c( , ) or list( , ) with a dataframe? Thank you for your help. Sincerely, Mary A. Marion [[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] math symbols in R
Hello, I would like R software to printout a sentence including a statement such as Ho: mu=5 vs Ha: mu ne 5 where ne stands for the math symbol notequal and mu is greek letter for u. How to do? Most of the help questions I have seen have been those involving graphs. Thank you. Sincerely, Mary A. Marion __ 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] IF STATEMENTS
Hello, I am working on using if statements. What is the error message telling me here and how do I correct for it? I have tried various combinations of quotes. Thank you. Sincerely, Mary A. Marion #Find critical values crit<-function(n,alpha,type) { if (type==twoSided) { alpha2=alpha/2 tL<-qt(alpha2,n-1) tU<-qt(1-alpha2,n-1) } if (type==Lower) { tL<- - tU<-qt(1-alpha,n-1) } if (type==Upper) { tL<-qt(alpha,n-1) tU<- } criticalValues<-c(tL,tU) round(criticalValues,3) } crit(n=50,alpha=.05,type=twoSided) Error in crit(n = 50, alpha = 0.05, type = twoSided) : object 'twoSided' not found > crit(n=50,alpha=.05,type=Lower) crit(n=50,alpha=.05,type=Upper) __ 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] mathematical notation in R
Hello, I have an R function which includes the statement LBAuo<- -. Rather than printing out - I want it to print out - infinity. As of yet I have not been able to do that. I am not in a graphics window just outputting a set of variables. Can you help? Thanks. Sincerely, Mary A. Marion __ 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] graphs
Hello, I am plotting two distributions and want to draw a vertical line at the critical point 149. How can I stop it from going further up than the norm(140,15) curve? x<-seq(75,225,0.1) plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy') abline(v = 149, col = "black") curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE) Thank you. Sincerely, Mary A. Marion __ 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] formatting in r
Hello, I have output that I want to print out. I am having a few issues. 1] output u to power is really nothing more than a 2 x 11 set of values formed using cbind function and printed out as a data frame How can I get it to output over several lines such as seen here? 2] Critical Z etc. were added by hand. I need an example of how I can mix alphanumeric and numeric data on output. Can you assist? R is proving to be a really fine computational language that is easy to use. Thank you. Sincerely, Mary A. Marion u xbar alpha zcrit zcrit2 zstatpvalue 140 150.05 1.64491.96 4 6.334248e-05 LB95 UB95LB90UB90 145.1 154.9 145.888 154.112 Beta Power 0.021 0.979 Critical Z = 1.645 Zstatistic = 4 Empirical Mean 150[ 135.1, 144.9 ) = Ao(µo) Population Mean 140[ 145.1, 154.9 ] = C(x) Pvalue < .0001 __ 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] saving only part of a computation in integrate
Hello, I am using Beta <-integrate(dnorm,mean=0,sd=1,-Inf,2.3552) > Beta 0.9907436 with absolute error < 4.2e-06 1-Beta results in an error How can I store into Beta only .9907436? Thank you. Sincerely, Mary A. Marion __ 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.