[R] Removing description from lm()
Hi , When I run the following code , I get both the description and the value , eg : Intercept and 0.5714286. Is there a way to extract just the value 0.5714286? Thanks! x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y 0.5714 0.4286 lm(x~y)$coefficient[1](Intercept) 0.5714286 Regards Billy [[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] Removing description from lm()
On 05/10/2014, 7:21 AM, billy am wrote: Hi , When I run the following code , I get both the description and the value , eg : Intercept and 0.5714286. Is there a way to extract just the value 0.5714286? Thanks! x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y 0.5714 0.4286 lm(x~y)$coefficient[1](Intercept) 0.5714286 It's a name, not a description. The result is a named vector. To get rid of the name, call unname() on it, i.e. unname(lm(x~y)$coefficient[1]) Duncan Murdoch __ 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] Removing description from lm()
On 05.10.2014 15:02, Duncan Murdoch wrote: On 05/10/2014, 7:21 AM, billy am wrote: Hi , When I run the following code , I get both the description and the value , eg : Intercept and 0.5714286. Is there a way to extract just the value 0.5714286? Thanks! x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y 0.5714 0.4286 lm(x~y)$coefficient[1](Intercept) 0.5714286 It's a name, not a description. The result is a named vector. To get rid of the name, call unname() on it, i.e. unname(lm(x~y)$coefficient[1]) I guess the OP is going to use the name (here (Intercept) without the quotes) to extract the value, hence (also using the extractior function coef()): coef(lm(x~y))[(Intercept)] Best, Uwe Ligges Duncan Murdoch __ 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.
Re: [R] comparing two half-normal production stochastic frontier functions
Arne Henningsen arne.henning...@gmail.com writes: Dear Rainer On 3 October 2014 14:51, Rainer M Krug rai...@krugs.de wrote: I am using the function frontier::sfa (from the package frontier) to estimate several half-normal production stochastic frontier functions. Now I want to compare the coefficients of the linear frontier function and see if they are different. According to my stackexchange (CrossValidated) question [1] I can compare these as I can compare a normal linear regression. In R, I would uswe the function anova to do this model comparison - correct? Now this function does not accept objects of the type 'frontier' - so how can I do this comparison in R? To re-iterate, I want to know if the coefficients of the frontier line (slope and intercept) are significantly different. Below please find a reproducible example based on data provided in the package, of what I did, and below the transcript. --8---cut here---start-8--- library(frontier) data(front41Data) dat1 - front41Data[1:30,] dat2 - front41Data[30:60,] x1 - sfa(log(output) ~ log(capital), data=dat1) x2 - sfa(log(output) ~ log(capital), data=dat2) x1 x2 anova(x1, x2 --8---cut here---end---8--- library( frontier ) data( front41Data ) # estimate pooled model mp - sfa( log(output) ~ log(capital), data = front41Data ) # create a dummy variable front41Data$dum - rep( c( 1, 0 ), 30 ) # estimate model with different intercepts and different slopes # but the same sigmsSq and the same gamma md - sfa( log(output) ~ log(capital)*dum, data = front41Data ) # likelihood ratio test lrtest( mp, md ) If you have further questions regarding the frontier package, you may also use the help forum at frontier's R-Forge site: Thanks - I will follow this up there Rainer https://r-forge.r-project.org/projects/frontier/ ...and please do not forget to cite the frontier package in your publications (see output of the R command 'citation(frontier)'). Best regards, Arne -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug PGP: 0x0F52F982 pgp__mgp_73IY.pgp Description: PGP signature __ 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] Removing description from lm()
Thank you both very much. It is the unname that is what I am looking for. Thanks! Btw , must the [1] be there? I am writing a Shiny web app hence I would like to display the value alone. Thanks! unname(lm(x~y)$coefficient[1])[1] 0.5714286 coef(lm(x~y))[(Intercept)](Intercept) 0.5714286 On Sun, Oct 5, 2014 at 9:09 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 05.10.2014 15:02, Duncan Murdoch wrote: On 05/10/2014, 7:21 AM, billy am wrote: Hi , When I run the following code , I get both the description and the value , eg : Intercept and 0.5714286. Is there a way to extract just the value 0.5714286? Thanks! x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y 0.5714 0.4286 lm(x~y)$coefficient[1](Intercept) 0.5714286 It's a name, not a description. The result is a named vector. To get rid of the name, call unname() on it, i.e. unname(lm(x~y)$coefficient[1]) I guess the OP is going to use the name (here (Intercept) without the quotes) to extract the value, hence (also using the extractior function coef()): coef(lm(x~y))[(Intercept)] Best, Uwe Ligges Duncan Murdoch __ 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. [[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] Removing description from lm()
On 05/10/2014, 10:06 AM, billy am wrote: Thank you both very much. It is the unname that is what I am looking for. Thanks! Btw , must the [1] be there? I am writing a Shiny web app hence I would like to display the value alone. Try leaving it out, and you'll see what it's for. (It is generally pretty safe to experiment in R. Don't worry, you won't break it.) Duncan Murdoch Thanks! unname(lm(x~y)$coefficient[1]) [1] 0.5714286 coef(lm(x~y))[(Intercept)] (Intercept) 0.5714286 On Sun, Oct 5, 2014 at 9:09 PM, Uwe Ligges lig...@statistik.tu-dortmund.de mailto:lig...@statistik.tu-dortmund.de wrote: On 05.10.2014 15:02, Duncan Murdoch wrote: On 05/10/2014, 7:21 AM, billy am wrote: Hi , When I run the following code , I get both the description and the value , eg : Intercept and 0.5714286. Is there a way to extract just the value 0.5714286? Thanks! x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y 0.5714 0.4286 lm(x~y)$coefficient[1](__Intercept) 0.5714286 It's a name, not a description. The result is a named vector. To get rid of the name, call unname() on it, i.e. unname(lm(x~y)$coefficient[1]) I guess the OP is going to use the name (here (Intercept) without the quotes) to extract the value, hence (also using the extractior function coef()): coef(lm(x~y))[(Intercept)] Best, Uwe Ligges Duncan Murdoch R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/__listinfo/r-help 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. __ 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] Removing description from lm()
On 05 Oct 2014, at 16:06 , billy am wickedpu...@gmail.com wrote: Thank you both very much. It is the unname that is what I am looking for. Thanks! Btw , must the [1] be there? I am writing a Shiny web app hence I would like to display the value alone. It's part of standard printing of unnamed vectors. For nonstandard printing tasks, use cat() as in x -c(a=2) x a 2 cat(x,\n) 2 (which incidentally also gets rid of the name). -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] Removing description from lm()
Thats it! Most splendid! Thanks! The final result, just the value alone , for future reference. x - c(1,5,3,1) y - c(5,8,2,3) lm(x~y)$coefficient[1](Intercept) 0.5714286 cat(lm(x~y)$coefficient[1])0.5714286 Thanks everyone! Regards Billy On Sun, Oct 5, 2014 at 10:37 PM, peter dalgaard pda...@gmail.com wrote: On 05 Oct 2014, at 16:06 , billy am wickedpu...@gmail.com wrote: Thank you both very much. It is the unname that is what I am looking for. Thanks! Btw , must the [1] be there? I am writing a Shiny web app hence I would like to display the value alone. It's part of standard printing of unnamed vectors. For nonstandard printing tasks, use cat() as in x -c(a=2) x a 2 cat(x,\n) 2 (which incidentally also gets rid of the name). -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com [[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] truncated normal
Dear all R-users I have a question regarding truncated normal distribution : which type of probability distribution has same properties of truncated normal distribution? Many thanks in advance -- Thanoon Y. Thanoon PhD Candidate Department of Mathematical Sciences Faculty of Science University Technology Malaysia, UTM E.Mail: thanoon.youni...@gmail.com E.Mail: dawn_praye...@yahoo.com Facebook:Thanoon Younis AL-Shakerchy Twitter: Thanoon Alshakerchy H.P:00601127550205 [[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] truncated normal
This isn't an R question at all, so I don't know why it's on this list. But the best answer I've got is a truncated t-distribution with an infinite number of degrees of freedom. Bob On 5 October 2014 17:18, thanoon younis thanoon.youni...@gmail.com wrote: Dear all R-users I have a question regarding truncated normal distribution : which type of probability distribution has same properties of truncated normal distribution? Many thanks in advance -- Thanoon Y. Thanoon PhD Candidate Department of Mathematical Sciences Faculty of Science University Technology Malaysia, UTM E.Mail: thanoon.youni...@gmail.com E.Mail: dawn_praye...@yahoo.com Facebook:Thanoon Younis AL-Shakerchy Twitter: Thanoon Alshakerchy H.P:00601127550205 [[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. -- Bob O'Hara Biodiversity and Climate Research Centre Senckenberganlage 25 D-60325 Frankfurt am Main, Germany Tel: +49 69 798 40226 Mobile: +49 1515 888 5440 WWW: http://www.bik-f.de/root/index.php?page_id=219 Blog: http://occamstypewriter.org/boboh/ Journal of Negative Results - EEB: www.jnr-eeb.org [[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] Caret and Model Prediction
Dear All, I am learning the ropes of CARET for automatic model training, more or less following the steps of the tutorial at http://bit.ly/ZJQINa However, there are a few things about which I would like a piece of advice. Consider for instance the following model # set.seed(825) fitControl - trainControl(## 10-fold CV method = repeatedcv, number = 10, ## repeated ten times repeats = 10) gbmGrid - expand.grid(interaction.depth = c(1, 5, 9), n.trees = (1:30)*50, shrinkage = 0.05) nrow(gbmGrid) gbmFit - train(Ca+P+pH+SOC+Sand~ ., data = training, method = gbm, trControl = fitControl, ## This last option is actually one ## for gbm() that passes through verbose = TRUE, ## Now specify the exact models ## to evaludate: tuneGrid = gbmGrid ) # I am trying to tune a model that predicts the values of 5 columns whose names are Ca,P,pH, SOC, and Sand. 1) Am I using the formula syntax in a correct way? I then try to apply my model on the test data by coding mypred - predict(gbmFit, newdata=test) However, at this point I am left with a couple of questions 2) does predict automatically select the best tuned model in gbmFit? and if not, what am I supposed to do? 3) I do not get any error messages, but mypred consists of a single column instead of 5 columns corresponding to the 5 variables I am trying to predict, so something is obviously wrong (see point 1). Any suggestions here? Many thanks Lorenzo __ 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] truncated normal
Bob O'Hara rni.boh at gmail.com writes: This isn't an R question at all, so I don't know why it's on this list. But the best answer I've got is a truncated t-distribution with an infinite number of degrees of freedom. Bob Or, perhaps more productively: since your question is a general statistical question, it might be more useful to ask it (e.g.) on CrossValidated, http://stats.stackexchange.com ; however, you'll also need to expand and/or clarify your question before you ask it there. It's not clear what kinds of similarity and/or properties you are looking for. More context would be helpful. On 5 October 2014 17:18, thanoon younis thanoon.younis80 at gmail.com wrote: Dear all R-users I have a question regarding truncated normal distribution : which type of probability distribution has same properties of truncated normal distribution? Many thanks in advance __ 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] truncated normal
... yes. ... And do note that in sampling, truncated != censored. (They are often confused) Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Sun, Oct 5, 2014 at 9:32 AM, Ben Bolker bbol...@gmail.com wrote: Bob O'Hara rni.boh at gmail.com writes: This isn't an R question at all, so I don't know why it's on this list. But the best answer I've got is a truncated t-distribution with an infinite number of degrees of freedom. Bob Or, perhaps more productively: since your question is a general statistical question, it might be more useful to ask it (e.g.) on CrossValidated, http://stats.stackexchange.com ; however, you'll also need to expand and/or clarify your question before you ask it there. It's not clear what kinds of similarity and/or properties you are looking for. More context would be helpful. On 5 October 2014 17:18, thanoon younis thanoon.younis80 at gmail.com wrote: Dear all R-users I have a question regarding truncated normal distribution : which type of probability distribution has same properties of truncated normal distribution? Many thanks in advance __ 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.
Re: [R] Caret and Model Prediction
Hi, Lorenzo: For 1) I think the formula is not correct. The formula should be outcome ~ features, and that's why you have weird result in 3) 2) predict in caret will automatically find the best result one if there is one(sometimes it fails). You can print the model to see the cross validation result. Furthermore, you may specify the performance metric you want to find the optimal result. Please see the details of the caret tutorial to see how to. On Sun, Oct 5, 2014 at 8:54 AM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, I am learning the ropes of CARET for automatic model training, more or less following the steps of the tutorial at http://bit.ly/ZJQINa However, there are a few things about which I would like a piece of advice. Consider for instance the following model # set.seed(825) fitControl - trainControl(## 10-fold CV method = repeatedcv, number = 10, ## repeated ten times repeats = 10) gbmGrid - expand.grid(interaction.depth = c(1, 5, 9), n.trees = (1:30)*50, shrinkage = 0.05) nrow(gbmGrid) gbmFit - train(Ca+P+pH+SOC+Sand~ ., data = training, method = gbm, trControl = fitControl, ## This last option is actually one ## for gbm() that passes through verbose = TRUE, ## Now specify the exact models ## to evaludate: tuneGrid = gbmGrid ) # I am trying to tune a model that predicts the values of 5 columns whose names are Ca,P,pH, SOC, and Sand. 1) Am I using the formula syntax in a correct way? I then try to apply my model on the test data by coding mypred - predict(gbmFit, newdata=test) However, at this point I am left with a couple of questions 2) does predict automatically select the best tuned model in gbmFit? and if not, what am I supposed to do? 3) I do not get any error messages, but mypred consists of a single column instead of 5 columns corresponding to the 5 variables I am trying to predict, so something is obviously wrong (see point 1). Any suggestions here? Many thanks Lorenzo __ 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. -- Jia Xu [[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] n-gram error with packages tau, tm, RTextTools
Hi: I am trying to compute n-grams using package tm and tau with following code: tokenize_ngrams - function(x, n=3) return(rownames(as.data.frame(unclass(textcnt(x,method=string,n=n) texts - c(This is the first document., This is the second file., This is the third text.) corpus - Corpus(VectorSource(texts)) matrix - DocumentTermMatrix(corpus,control=list(tokenize=tokenize_ngrams)) And getting following error Error in FUN(X[[2L]], ...) : non-character argument also getting same error using the RTextTools package. Any solution? Best regards: John __ 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] Caret and Model Prediction
Thanks a lot. At this point then I wonder: seen that my response consists of 5 outcomes for each set of features, should I then train 5 different models (one for each of them)? Cheers Lorenzo On Sun, Oct 05, 2014 at 11:04:01AM -0700, Jia Xu wrote: Hi, Lorenzo: For 1) I think the formula is not correct. The formula should be outcome ~ features, and that's why you have weird result in 3) 2) predict in caret will automatically find the best result one if there is one(sometimes it fails). You can print the model to see the cross validation result. Furthermore, you may specify the performance metric you want to find the optimal result. Please see the details of the caret tutorial to see how to. On Sun, Oct 5, 2014 at 8:54 AM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, I am learning the ropes of CARET for automatic model training, more or less following the steps of the tutorial at http://bit.ly/ZJQINa However, there are a few things about which I would like a piece of advice. Consider for instance the following model # set.seed(825) fitControl - trainControl(## 10-fold CV method = repeatedcv, number = 10, ## repeated ten times repeats = 10) gbmGrid - expand.grid(interaction.depth = c(1, 5, 9), n.trees = (1:30)*50, shrinkage = 0.05) nrow(gbmGrid) gbmFit - train(Ca+P+pH+SOC+Sand~ ., data = training, method = gbm, trControl = fitControl, ## This last option is actually one ## for gbm() that passes through verbose = TRUE, ## Now specify the exact models ## to evaludate: tuneGrid = gbmGrid ) # I am trying to tune a model that predicts the values of 5 columns whose names are Ca,P,pH, SOC, and Sand. 1) Am I using the formula syntax in a correct way? I then try to apply my model on the test data by coding mypred - predict(gbmFit, newdata=test) However, at this point I am left with a couple of questions 2) does predict automatically select the best tuned model in gbmFit? and if not, what am I supposed to do? 3) I do not get any error messages, but mypred consists of a single column instead of 5 columns corresponding to the 5 variables I am trying to predict, so something is obviously wrong (see point 1). Any suggestions here? Many thanks Lorenzo __ 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. -- Jia Xu __ 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] loop
Hello ,I am trying to write a loop for sum of integrals . the integral is:integrand4-function(x,a=1.5,n=3,k=0){(((a+1)*x)^k)*((2-x)^n)*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand4,0,2). I need a loop to give me the sum of integrals over k = 0,.n , for every positive integer input (n).can anybody check my program and tell me about it's problem?I am looking forward to your suggestions. B-function(n){Sum-1for (k in 0:n){BB-function(k){integrand2-function(x,a=1.5){(((a+1)*x)^k)*((2-x)^(n))*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand2,0,2)}r-print(BB(k))sum-sum+r}print(sum-1)} Best Regards,Diba [[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] CRAN (and crantastic) updates this week
CRAN (and crantastic) updates this week New packages * activity (1.0) Maintainer: Marcus Rowcliffe Author(s): Marcus Rowcliffe marcus.rowcli...@ioz.ac.uk License: GPL-3 http://crantastic.org/packages/activity Provides functions to fit kernel density functions to animal activity time data; plot activity distributions; quantify overall levels of activity; statistically compare activity metrics through bootstrapping; and evaluate variation in linear variables with time (or other circular variables). * atmcmc (1.0) Maintainer: Jinyoung Yang Author(s): Jinyoung Yang License: GPL (= 2) http://crantastic.org/packages/atmcmc Uses adaptive diagnostics to tune and run a random walk Metropolis MCMC algorithm, to converge to a specified target distribution and estimate means of functionals. * blocksdesign (1.1) Maintainer: Rodney Edmondson Author(s): R. N. Edmondson License: GPL (= 2) http://crantastic.org/packages/blocksdesign Nested block designs for unstructured treatment sets where blocks can be repeatedly nested and treatments can have different levels of replication. Blocks strata are optimized hierarchically with each set of nested blocks optimized within the levels of the preceding set. Block sizes are equal if the number of blocks exactly divides the number of plots, otherwise they differ by at most one plot. The design output is a data table giving a randomised allocation of treatments to blocks together with a plan table showing treatments in blocks and a set of blocks-by-treatments incidence matrices, one for each blocks stratum. * checkpoint (0.3.2) Maintainer: Andrie de Vries Author(s): Revolution Analytics License: GPL-2 http://crantastic.org/packages/checkpoint The goal of checkpoint is to solve the problem of package reproducibility in R. Specifically, checkpoint allows you to install packages as they existed on CRAN on a specific snapshot date as if you had a CRAN time machine. To achieve reproducibility, the checkpoint() function installs the packages required or called by your project and scripts to a local library exactly as they existed at the specified point in time. Only those packages are available to your project, thereby avoiding any package updates that came later and may have altered your results. In this way, anyone using checkpoint#39;s checkpoint() can ensure the reproducibility of your scripts or projects at any time. To create the snapshot archives, once a day (at midnight UTC) we refresh the Austria CRAN mirror, on the quot;Managed R Archived Networkquot; server (http://mran.revolutionanalytics.com/). Immediately after completion of the rsync mirror process, we take a snapshot, thus creating the archive. Snapshot archives exist starting from 2014-09-17. * DynNom (1.0) Maintainer: Amirhossein Jalali Author(s): Amirhossein Jalali, Alberto Alvarez-Iglesias, John Newell License: GPL-2 http://crantastic.org/packages/DynNom The DynNom function makes it possible to present the results of an lm or glm model object as a dynamic nomogram that can be displayed in an R Studio panel or web browser. * enpls (1.0) Maintainer: Xiao Nan Author(s): Nan Xiao road2s...@gmail.com, Dong-Sheng Cao oriental-...@163.com, Qing-Song Xu dason...@gmail.com License: GPL (= 2) http://crantastic.org/packages/enpls R package for ensemble partial least squares regression, a unified framework for feature selection, outlier detection, and ensemble learning. * gender (0.4.1) Maintainer: Lincoln Mullen Author(s): Lincoln Mullen [aut, cre], Cameron Blevins [ctb], Ben Schmidt [ctb] License: MIT + file LICENSE http://crantastic.org/packages/gender Encodes gender based on names and dates of birth, using either the Social Security Administration#39;s data set of first names by year of birth or Census Bureau data from 1789 to 1940, both from the United States of America. By using these data sets instead of lists of male and female names, this package is able to more accurately guess the gender of a name, and it is able to report the probability that a name was male or female. * lazyeval (0.1.9) Maintainer: Hadley Wickham Author(s): Hadley Wickham [aut, cre], RStudio [cph] License: GPL-3 http://crantastic.org/packages/lazyeval A disciplined approach to non-standard evaluation. * mdsdt (1.0) Maintainer: Robert X.D. Hawkins Author(s): Robert X.D. Hawkins r...@stanford.edu, Joe Houpt joseph.ho...@wright.edu, Noah Silbert noahp...@gmail.com, Leslie Blaha leslie.bl...@wpafb.af.mil, Thomas D. Wickens twick...@socrates.berkeley.edu License: GPL (= 2) http://crantastic.org/packages/mdsdt This package contains a series of tools associated with General Recognition Theory (Townsend amp; Ashby, 1986), including Gaussian model fitting of 4x4 and more general confusion
Re: [R] loop
Please don't post in HTML since your code was all messed up. You did not mention what problems you were having with your code. Now a couple of things to check is to look at what the structure of r that you are trying to add to sum (which should have been Sum according to your assignment earlier in the function.). Browse[1] str(r) List of 5 $ value : num 0.0548 $ abs.error : num 6.08e-16 $ subdivisions: int 1 $ message : chr OK $ call: language integrate(f = integrand2, lower = 0, upper = 2) - attr(*, class)= chr integrate shows that r is a list and you want r$value to do the addition. So after formatting your code, and making a couple of corrections, is this what you were expecting to see: B-function(n){ + Sum-1 + for (k in 0:n){ + BB-function(k){ + integrand2-function(x,a=1.5){ + (((a+1)*x)^k)*((2-x)^(n))*(exp(-a*x-2))/(factorial(k)*factorial(n)) + } + integrate(integrand2,0,2) + } + r-BB(k) + print(r) + Sum-Sum+r$value + } + print(Sum-1) + } B(3) 0.05479674 with absolute error 6.1e-16 0.03780519 with absolute error 4.2e-16 0.02371485 with absolute error 2.6e-16 0.01355982 with absolute error 1.5e-16 [1] 0.1298766 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Oct 5, 2014 at 6:01 PM, pari hesabi statistic...@hotmail.com wrote: Hello ,I am trying to write a loop for sum of integrals . the integral is:integrand4-function(x,a=1.5,n=3,k=0){(((a+1)*x)^k)*((2-x)^n)*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand4,0,2). I need a loop to give me the sum of integrals over k = 0,.n , for every positive integer input (n).can anybody check my program and tell me about it's problem?I am looking forward to your suggestions. B-function(n){Sum-1for (k in 0:n){BB-function(k){integrand2-function(x,a=1.5){(((a+1)*x)^k)*((2-x)^(n))*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand2,0,2)}r-print(BB(k))sum-sum+r}print(sum-1)} Best Regards,Diba [[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-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.