Re: [R] two questions about character manipulation
Dear Rui Barradas and Michael Weylandt, Many thanks for your replies. My second question is solved now. But I think I did not expressed my first wish in a clear way Indeed, in ex<-"cbind(data$response1,data$response2), I want to extract the variable name between "$" and "," (corresponds to response1 in this example) and the one between "$" and ")" (corresponds to response2). These symbols ("$", ",", ")" ) are always same, but the names (response1, response2) might change from data to data. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/two-questions-about-character-manipulation-tp4643292p4643301.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] Usage of trim in mean()
trim is for calculating trimmed mean such that "the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed" from ?help(mean) Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Usage-of-trim-in-mean-tp4643281p4643293.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.
[R] two questions about character manipulation
Dear all, I want to manipulate a character string such as ex<-"cbind(data$response1,data$response2)" in R in two ways: 1) extracting the "response1" portion of ex 2) replacing "$" with "." I am wondering that is it possible efficiently doing these in R? Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/two-questions-about-character-manipulation-tp4643292.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.
[R] concatenating two vectors
Dear all, I want to concatenate the elements of two vectors such as a<-c("a1","a2") b<-c("b1","b2") and obtain "a1b1", "a1b2","a2b1","a2b2" I tried the paste and paste0 functions, but they yielded elementwise concatenation such as "a1b1","a2b2" I am wondering that is there an efficient way of doing my wish, for instance without using for loop etc. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/concatenating-two-vectors-tp4643139.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] empty cell when running GEE for binary data
Dear Yu, What do you mean exactly by "exmpty cell" ? But you can try, the following packages which might help you: gee and yags. But I am not sure. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/empty-cell-when-running-GEE-for-binary-data-tp4635483p4635504.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] estimating parameters of a model
You can be sure that it is reliable! Ozgur -- View this message in context: http://r.789695.n4.nabble.com/estimating-parameters-of-a-model-tp4634808p4634811.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] Error: could not find function
How do I load the package again (install it from server again?) library(omega) there a way to check which workspace was used in history? Unless you do not save it, you will use a fresh one. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Error-could-not-find-function-tp4634716p4634738.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] remove descriptions from output
Dear Kathie, Try c(filter(1:10, rep(1, 3))) Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/remove-descriptions-from-output-tp4634723p4634727.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] Error: could not find function
Dear codec cat, Once you installed an R package, you do not have to install it again. But, you have to load the package when you change your workspace. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Error-could-not-find-function-tp4634716p4634726.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] shapiro.test()
Actually, your sample size is 3. Sorry for that. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/shapiro-test-tp4634513p4634525.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] shapiro.test()
See ?shapiro.test ...the number of non-missing values must be between 3 and 5000. By the way, how reasonable testing normality of 3 values? Best ozgur -- View this message in context: http://r.789695.n4.nabble.com/shapiro-test-tp4634513p4634520.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] How to calculate the predicted value by using GAMs?
See ?predict.gam Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/How-to-calculate-the-predicted-value-by-using-GAMs-tp4634317p4634384.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] significance level (p) for t-value in package zelig
Michael, Try ?pt Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/significance-level-p-for-t-value-in-package-zelig-tp4634252p4634271.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] lmomco in gev estimation
Hi Al Ehan, Alternatively you can gev.fit functions under the packages "ismev" and "extRemes". Hope these help you. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/lmomco-in-gev-estimation-tp4633931p4633941.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] Need help in using "OPTIM / OPTIMIZATION" function
rehena wrote > > Hi Ozgur, > > Many thanks for your help. > > May be I am not very strong enough in the OPTIMIZATION field. Can I check > with you whether second derivative of the function at global max will be > less than 0 and will be greater than 0 at local max? > > Thanks in advance. > > Regards, > rehena > Dear rehena, If you want to check whether the second derivative is negative by OOmisc, the answer is no. You an derive the derivatives by hand and code in R. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Need-help-in-using-OPTIM-OPTIMIZATION-function-tp4633796p4633924.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] Need help in using "OPTIM / OPTIMIZATION" function
Dear rehena, You can use optim() with method="Brent", or optimize() directly, for your case. But for you case, a popular approach is Newton-Raphson root finding algorithm. You can use newton function under my package OOmisc. You can check whether the global maximum or local maximum is found by replacing the solution in the second derivative of the log-likelihood function and if its value at the solution is less than 0, you can be sure that global maximum is secured. Hope this helps Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Need-help-in-using-OPTIM-OPTIMIZATION-function-tp4633796p4633921.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] QQplot normally distributed
>Hi, >So in my example, I can say that the data comes from a moderate normal distribution because the points more at the >right lay straight to a straight line, then the points at the left. Please a confirmation here. >But what is the information above (that the data is from a normal distribution) say about the relationship between two >variables? Dear Noor, Which two variables? Ozgur -- View this message in context: http://r.789695.n4.nabble.com/QQplot-normally-distributed-tp4633819p4633920.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] QQplot normally distributed
Dear Liviu , Why do you prefer robust methods in the example of Noor and why you need exact normality here? Ozgur -- View this message in context: http://r.789695.n4.nabble.com/QQplot-normally-distributed-tp4633819p4633919.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] Subset of summary results
>yes, it gives me the required summary statistics with the following command >summary(Mnp)$coef.table[c(1:3,5,6,8,9,11,12,14,15,17,18),] >Normally if we compare the two summary results before and after skipping some variables, we note bit change in >the estimates of the rest of the variables. But in this case, it shows the same. I want to ask are the results in this case >valid and publishable? I expect difference as well. You can try assigning two models to different objects such as Mnp1 and Mnp2, then try to extract interested statistics from them and compare the results. >Thanks -- View this message in context: http://r.789695.n4.nabble.com/Subset-of-summary-results-tp4633821p4633873.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] Subset of summary results
What about summary(model)$coefficients[,1] ? ozgur -- View this message in context: http://r.789695.n4.nabble.com/Subset-of-summary-results-tp4633821p4633832.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] QQplot normally distributed
Hi, Try boxplot for outliers. To decide whether they influence significantly, try confirmatory normality tests. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/QQplot-normally-distributed-tp4633819p4633830.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] Subset of summary results
Did you try summary(model)$coefficients summary(model)$covariances names(model) would help you as well. ozgur -- View this message in context: http://r.789695.n4.nabble.com/Subset-of-summary-results-tp4633821p4633822.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] QQplot normally distributed
Hi, Following a straight line indicates less evidence towards non-normality. But QQ-Plot is an exploratory tool. You can confirm your ideas obtained from the QQ-Plot via noramlity tests such as Shapiro-Wilk test. See shapiro.test under stats package and nortest package. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/QQplot-normally-distributed-tp4633819p4633820.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] multiplicative error model
What do you mean by using the package? Aren't the examples in the package manual at http://cran.r-project.org/web/packages/dynamo/dynamo.pdf enough for you? Ozgur -- View this message in context: http://r.789695.n4.nabble.com/multiplicative-error-model-tp4633730p4633732.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] Loop Help
@angel, You can try append option in write.table for e.g. for(i in 1:20) write.table(i,"out.txt",append=T,sep="\t",row.names=F,col.names=F) This will help you save your all results by writing each results on subsequent rows. Hope this helps Ozgur >Hello Jim >thank you so much for your response. >When I use write.csv, on the csv file is saved only the last loop >So when I write >results.matrix <- apply(degree_w(net.static[[i]]), 2, mean) >write.csv(results.matrix, file = "results.csv") >instead of getting a 550 line document with all loop results, I only get the last one! >Could you please help me? >Thank you so much in advance -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633722.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] Loop Help
Hi, Do you mean printing the results of degree_w(net.101031) and apply(net.101031, 2, mean) in a loop? see ?print to print the results and ?cat as a suporting function. For instance see the toy example below for (i in 1:5){ print('') cat("model",i,"\n") print(summary(lm(rnorm(10,0,1)~rnorm(10,0,2 } Hope this helps Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633572.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] p-values from lm()
Dear David, Try summary(mod1)$coef[,4] Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/p-values-from-lm-tp4633357p4633361.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] Compare two matrices in r
See the example at http://onertipaday.blogspot.com/2007/05/comparing-two-matrices-row-by-row.html Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Compare-two-matrices-in-r-tp4633082p4633087.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] Lmer coef table
Dear Andrew, latextable function under the R package miscFuncs might help you preparing a LATEX table in R. For the usage, see an example on the webpage of the author of the package at http://www.lancs.ac.uk/staff/taylorb1/ Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Lmer-coef-table-tp4632967p4632981.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] mvrnorm limits
Dear Andras, More to the point, the distribution might not be multivariate normal. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/mvrnorm-limits-tp4632913p4632930.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] Order all the columns ascending elements on a matrix or a data frame
Try apply(b,2,sort) best ozgur -- View this message in context: http://r.789695.n4.nabble.com/Order-all-the-columns-ascending-elements-on-a-matrix-or-a-data-frame-tp4632922p4632924.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] "Re-creating" distributions
Of course, if you have data points at hand. Thanks Bert, for pointing out. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Re-creating-distributions-tp4632739p4632849.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] Problem with sample function
Dear Guido, Try prov2<-prov[sample(1:nrow(prov),5,replace=F),] which corresponds to without replacement sampling. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-sample-function-tp4632835p4632836.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] "Re-creating" distributions
Dear Andras, A possible option might be checking the fit of your data to a specific distribution and generating the data from the distribution to which your data fit, with the parameters such as the MLE of them obtained by using the avaiable data. For instance, you can check whether your data is a random sample from multivariate normal distribution by using the R function mshapiro.test (under mvnormtest) and estimate MLE of the parameters by using the function mlest (under mvnmle). Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Re-creating-distributions-tp4632739p4632833.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] Determinant and inverse using cholsky parameter
Hi, Isn't the Cholesky decomposition of A=L (L)^T where T stands for "transpose" and L is the Cholesky factor of A. You say you have the Cholesky decomposition, isn't it L (above)? A<-L%*%t(L) det(A) solve(A) would be your answer. Hope this helps Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Determinant-and-inverse-using-cholsky-parameter-tp4632769p4632808.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] Rare event in logistic regression
Hi, Please see the discussion at http://r.789695.n4.nabble.com/regression-methods-for-rare-events-td4632332.html Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Rare-event-in-logistic-regression-tp4632656p4632658.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] - detecting outliers
Hi, I believe that first learning the appropriate statistical methods to detect the outliers and searching for the related functions in R is a better way. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/detecting-outliers-tp4632636p4632637.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] Creating frequency table using conditions in a for-loop
Hi, Where you attached the file? You can share your problem here as well. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Creating-frequency-table-using-conditions-in-a-for-loop-tp4632630p4632638.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] Sobel's test for mediation and lme4/nlme
Why posting the same message three times? Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Sobel-s-test-for-mediation-and-lme4-nlme-tp4632586p4632625.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] cluster algorithm with fixed cluster size
Hi, See the package cluster in R. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/cluster-algorithm-with-fixed-cluster-size-tp4632523p4632540.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] regression methods for rare events?
relogit procedure under package Zelig ? Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/regression-methods-for-rare-events-tp4632332p4632501.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] Ifelse on matrix using a vector argument
A generalized procedure for real life datasets might be out<-rep(matrix(arg),ncol(ma))-ma out[which(arg==0),]<--out[which(arg==0),] out Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Ifelse-on-matrix-using-a-vector-argument-tp4632485p4632490.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] Ifelse on matrix using a vector argument
Hi, A practical way migh be > out<-rep(matrix(arg),4)-ma > out[2,]<--out[2,];out[5,]<--out[5,] > out [,1] [,2] [,3] [,4] [1,] 0.8 0.4 0.80 1.0 [2,] 1.0 0.0 1.00 0.3 [3,] 0.7 0.9 0.65 1.0 [4,] 1.0 0.5 0.60 0.9 [5,] 0.5 1.0 0.00 1.0 Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Ifelse-on-matrix-using-a-vector-argument-tp4632485p4632487.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] How to calculate chi sqaure value from statistical value and degrees of freedom?
Hi, Actually, pchisq(q,df) calculates the cumulative distribution function by default. To calculate the p-value, you can use either 1-pchisq(q,df) or pchisq(q,df,lower.tail=FALSE) PS: I checked, the p value yielded by R and the calculator for which you give a link, for some "q" and "df" values, and these two are same. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385p4632470.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] Summarizing a matrix
Hi, x<-matrix(0,80,ncol=1) will create x matrix with all elements 0 (to be filled by the sums that you need) sum(y[y[,4]==1,5]) will calculate the sum of 5th column of y with 4th column=1 Similarly, sum(y[y[,4]==80,5]) will calculate the sum of 5th column of y with 4th column=80. You can adapt this to your case, with simple loops, etc. Hope this helps. Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Summarizing-a-matrix-tp4632319p4632381.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] How to calculate chi sqaure value from statistical value and degrees of freedom?
Hi, Try pchisq(q,df) available at help(Chisquare) Ozgur -- View this message in context: http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385p4632386.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] Merror
I believe that dozens of people asked this question before you. If you search this error in "google", you can find your answer! Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Merror-tp4632371p4632378.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] POT Package
Hi, You assumed scale=229678.21 and shape=0.41 and the procedure estimated \hat{scale}=427196.6 and \hat{shape}=0.2092887 I think these estimates are natural, since 1) you use a simulated generated data with n=100, and 2) the true value your scale parameter is very large. Hope this helps Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/POT-Package-tp4632055p4632065.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] Warning message: numerical expression has 1000 elements: only the first used
Hi, Your mistake seems to be in sum(v[1:x]) You create "x" as a vector but your treat it as a single number. v[1:x] expects "x" to be a single number and only considers its first element which is 1. If I understand your query correctly, the following might handle your problem: sum.vec <-NULL for (x in 1:1000){ t <- rbinom(1000, 1, 0.5) v <- replace(t,t==0,-1) sum.vec<-c(sum.vec,sum(v[1:x])) } Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Warning-message-numerical-expression-has-1000-elements-only-the-first-used-tp4631813p4631903.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] Loop question
Dear Sebastian, The following will create the names paste("sb",1:5,sep="") paste("sw",1:5,sep="") paste("Lw",1:5,sep="") paste("Lb",1:5,sep="") Then you can easily combine and/or order them in R. Hope this helps. Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Loop-question-tp4631896p4631900.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] Matrix Header Name Select
Sorry, I misunderstood your question. colnames(mymatrix) would select column names of your matrix. Best ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Matrix-Header-Name-Select-tp4631682p4631684.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] Matrix Header Name Select
Hi, You can try: colnames(mymatrix)<-NULL Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Matrix-Header-Name-Select-tp4631682p4631683.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] simulation of levene's test
Dear Dila, Try the following: library(Rcmdr) asim <- 1000 pv<-NULL for(i in 1:asim) { print(i) set.seed(i) g1 <- rnorm(20,0,2) g2 <- rnorm(20,0,2) g3 <- rnorm(20,0,2) x <- c(g1,g2,g3) group<-as.factor(c(rep(1,20),rep(2,20),rep(3,20))) pv<-c(pv,leveneTest(x,group)$"Pr(>F)"[1]) } Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/simulation-of-levene-s-test-tp4631578p4631600.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] Customized R Regression Output?
Dear Bert Gunter, Doesn't the summary(lm1)$coef have a matrix form? Then, while working with columns of a matrix, can't one use c/rbind functions? But list seem to better for what Chris asked. Nonetheless, c does not. Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Customized-R-Regression-Output-tp4631497p4631531.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] Customized R Regression Output?
Your welcome, To extract R squared values, you can use summary(lm1)$r.squared and include it in the cbind as result1<-cbind(summary(lm1)$coef[,1],summary(lm1)$coef[,1],summary(lm1)$r.squared) To add the results of multiple outputs you can use rbind such as rbind(result1,result2) where result2 is the output of the second model. Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Customized-R-Regression-Output-tp4631497p4631507.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] Customized R Regression Output?
Sorry for my typo, Last line of the R script should be >cbind(summary(lm1)$coef[,1],summary(lm1)$coef[,4]) # obtaining the estimates and related p-values Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Customized-R-Regression-Output-tp4631497p4631501.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] Customized R Regression Output?
Dear Christian, An illustrative and simple example follows: > y<-rnorm(100,0,1) #response variable > x1<-rnorm(100,0,1) #1st covariate > x2<-rnorm(100,0,1) #2nd covariate > > lm1<-lm(y~x1+x2) #fitting a linear model > cbind(summary(lm1)$coef[,1],summary(lm1)$coef[,1]) # obtaining the > estimates and related p-values [,1][,2] (Intercept) -0.02997559 -0.02997559 x1 -0.06170968 -0.06170968 x2 -0.12740465 -0.12740465 Here, the 1st column corresponds tı the estimates and 2nd one correspnds to the related p-values. I think you can easily adapt this to your datasets and combine muliple results of multiple datasets. Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Customized-R-Regression-Output-tp4631497p4631499.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] How to measure level of similarity of two data frames
Hi, You can try rdist function under the package fields, or dist package under stats package. Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/How-to-measure-level-of-similarity-of-two-data-frames-tp4631466p4631470.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] Special characters in an R package manual
Yes, in the .Rd file. \eqn is my cure. Thank you very much. Best ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Special-characters-in-an-R-package-manual-tp4631043p4631046.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.
[R] Special characters in an R package manual
Dear all, I have some trouble with special characters while building my R package. I tried to follow the usual LATEX format, but could not fix the problem: For instance, for "greater than or equal", I tried "\geq", but R says that this is an unknown macro. Could anyone direct me how to solve this issue? Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/Special-characters-in-an-R-package-manual-tp4631043.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] how to divide data by week
Dear Stefano, A practical way might be as the following R> acc<-read.table("acc.txt",header=T) #reading your data into R R> acc.may<-acc[acc[,3]==5,] #subsetting data with respect to may R> acc.may.order<-acc.may[order(acc.may[,4]),] #ordering with respect to day R> mean(acc.may.order[1:7,5]) # mean of the period of day 1 to 7 R> mean(acc.may.order[8:14,5]) # mean of the period of day 8 to 15 This script is just for May and taking means needs manual manipulations. On the other hand, simple loops might deal with your problem such as for loop. Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 http://www.stat.metu.edu.tr/people/assistants/ozgur/ -- View this message in context: http://r.789695.n4.nabble.com/how-to-divide-data-by-week-tp4556650p4556740.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] vif calculation with car and HH packages
Dear Prof. Fox, I got the point, things are clear now. Thank you very much, Best wishes Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 -- View this message in context: http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555653.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.
[R] vif calculation with car and HH packages
Dear all, I have faced a problem while calculating VIF values via the packages, car and HH for the models witout intercepts. Below is an illustrative example: 1) via the car package > y<-rnorm(100,0,1) > x1<-rnorm(100,0,1) > x2<-rnorm(100,0,1) > x3<-rnorm(100,0,1) > model1<-lm(y~-1+x1+x2+x3) > model2<-lm(y~-1+x1+x2) >library(car) > vif(model1) x1 x2 x3 1.000279 1.019231 1.019376 Warning message: In vif.lm(model1) : No intercept: vifs may not be sensible. > vif(model2) x1 x2 1.85 1.85 Warning message: In vif.lm(model2) : No intercept: vifs may not be sensible. 2) via the HH package > library(HH) > vif(model1) x2 x3 1.000557 1.000557 > vif(model2) Error in vif.default(xx, na.action = na.action) : vif requires two or more X-variables. I could not understand why this occured. Does anyone have any idea about it? Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 -- View this message in context: http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555402.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] submission of some functions to base package
Thank you very much Duncan Murdoch and bbolker. I see the process and will put those functions to my own package. Best ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 -- View this message in context: http://r.789695.n4.nabble.com/submission-of-some-functions-to-base-package-tp4441804p4443018.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.
[R] submission of some functions to base package
Dear all, Actually I could not decide who to contact, then decided to post here. If not appropriate sorry for that. I have written some functions in R which might be supposed to available in the base package but not available. I am wondering that how can I submit those functions to that package? Best Ozgur - Ozgur ASAR Research Assistant Middle East Technical University Department of Statistics 06531, Ankara Turkey Ph: 90-312-2105309 -- View this message in context: http://r.789695.n4.nabble.com/submission-of-some-functions-to-base-package-tp4441804p4441804.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.
[R] help on SAS Macro in R
Dear Researchers, I am looking for to read a SAS macro in R. Although I searched it on web, I couldnât find anything. Can you help me or direct me? Thank you for your interest and patience. Best. Ozgur [[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.