similar to: for loop not working in function

Displaying 20 results from an estimated 10000 matches similar to: "for loop not working in function"

2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Thanks John. ?boxcox says: ************************* Arguments object a formula or fitted model object. Currently only lm and aov objects are handled. ************************* I read that as saying that boxcox(lm(z+1 ~ 1),...) should run without error. But it didn't. And perhaps here's why: BoxCoxLambda <- function(z){ b <- MASS:::boxcox.lm(lm(z+1 ~ 1), lambda = seq(-5, 5,
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Hi Bert, On 2023-07-08 3:42 p.m., Bert Gunter wrote: > Caution: This email may have originated from outside the organization. Please exercise additional caution with any links and attachments. > > > Thanks John. > > ?boxcox says: > > ************************* > Arguments > > object > > a formula or fitted model object. Currently only lm and aov objects
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Dear Ron and Bert, First (and without considering why one would want to do this, e.g., adding a start of 1 to the data), the following works for me: ------ snip ------ > library(MASS) > BoxCoxLambda <- function(z){ + b <- boxcox(z + 1 ~ 1, + lambda = seq(-5, 5, length.out = 101), + plotit = FALSE) + b$x[which.max(b$y)] + } > mrow <- 500
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
No, I'm afraid I'm wrong. Something went wrong with my R session and gave me incorrect answers. After restarting, I continued to get the same error as you did with my supposed "fix." So just ignore what I said and sorry for the noise. -- Bert On Sat, Jul 8, 2023 at 8:28?AM Bert Gunter <bgunter.4567 at gmail.com> wrote: > Try this for your function: > >
2006 Jul 29
1
boxcox transformation
I've got a vector of data (hours to drive from a to b) y. After a qqplot I know, that they don't fit the normal probability. I would like to transform these data with the boxcox transformation (MASS), that they fit the model. When I try ybx<-boxcox(y~1,0) qqnorm(ybx) the plot is different from library (TeachingDemos) ybct<-bct(y,0) // qqnorm(ybct) How can I transform
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Hi, Firstly, apologies as I have posted this on community.rstudio.com too. I want to optimise a Box-Cox transformation on columns of a matrix (ie, a unique lambda for each column). So I wrote a function that includes the call to MASS::boxcox in order that it can be applied to each column easily. Except that I'm getting an error when calling the function. If I just extract a column of the
2007 Jun 18
3
Inverse BoxCox transformation
Hi, I can't seem to find a function in R that will reverse a BoxCox transformation. Can somebody help me locate one please? Thanks in advance. Best wishes, Des [[alternative HTML version deleted]]
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Try this for your function: BoxCoxLambda <- function(z){ y <- z b <- boxcox(y + 1 ~ 1,lambda = seq(-5, 5, length.out = 61), plotit = FALSE) b$x[which.max(b$y)] # best lambda } ***I think*** (corrections and clarification strongly welcomed!) that `~` (the formula function) is looking for 'z' in the GlobalEnv, the caller of apply(), and not finding it. It finds
2006 Feb 09
3
about Cox-Box transformation
Dear R-users, I am using R version 1.8.0-1 under Suse 8.2. I need to use the boxcox command because I want to apply a Cox-Box transformation to a vector of rainfall values. Within the libraries, the MASS library is present, but I don't know whether this means that is automatically installed or not. The command doesn't work. What do I have to do in order to make it working? Is just a
2002 Mar 21
1
Wilks Lamba
Hi all, I can't figure out how to compute Wilks Lambda in a one way repeated measure design. My matrix looks like: > t2.m Blank ECR ENC UEA UED 1 -0.15 0.14 0.16 0.09 0.14 2 0.30 0.08 0.14 0.14 0.14 [...] where each row is a case and the columns are levels of one factor (named trial): > t2.fit <- manova(t2.m ~ 1) > summary(t2.fit, intercept=T,
2004 Mar 01
1
boxcox in MASS library
Help page for boxcox function in MASS library says that the transformation is y^lambda, which is different from the Y' = log(Y) if lambda = 0 , Y' = ((Y ^ lambda) - 1)/lambda otherwise I'm used to. Is this just a help page typo ? Thanks. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
2003 Jun 24
2
Haw I get best lambda in box-cox
Hi all, Does anyone know of a function that return the best lambda in box-cox transformation? many thanks for any help. -- Cristiane S. Rocha Laboratorio Genoma Funcional - Bioinform?tica Centro de Biologia Molecular e Engenharia Genetica Universidade Estadual de Campinas Campinas - SP - Brasil Tel:(19)3788-1119
2004 May 14
1
Problem with logtrans, from library MASS
Greetings all! This problem occurs using R 1.8.1 on Windows XP. I downloaded the binaries for R and all packages, including the VR bundle, in December 2003. The data consists of NZ$ prices and attributes for 643 cars. > summary(price) Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 14290 35800 48990 65400 79000 285000 2 > library(MASS) > boxcox(price
2009 May 19
4
nlrwr package. Error when fitting the optimal Box-Cox transformation with two variables
Dear all: I'm trying to fit the optimal Box-Cox transformation related to nls (see the code below) for the demand of money data in Green (3th Edition) but in the last step R gives the next error message. Error en `[.data.frame`(eval(object$data), , as.character(formula(object)[[2]])[2]) : undefined columns selected. ?Any idea to solve the problem? Thanks in advance,
2008 Jun 05
1
choosing an appropriate linear model
I am trying to model the observed leaching of wood preservative chemicals from treated wood during an outdoor experiment where leaching is caused by rainfall events. For each rainfall event, the amount of rainfall was recorded as well as the amount of preservative chemical leached. A number of climatic variables were measured, but the most important is the amount of rainfall. I have tried a
2004 Dec 20
1
why use profile likelihood for Box Cox transformation?
Hi All, I'm analysing some data that is conventionally modelled as log(Y) = a + bX + e. However, using the boxcox function, it appears that the optimum value of lambda is approx 0.05. I have 40 data sets of differing sizes and for about half of these, lambda is significantly non-zero. So, it is worth looking into. The alternative model, Y^lambda = a + bX + e, has been explored before by
2013 Mar 11
1
Implementation of the PL2 weighting scheme of the DFR Framework
Hello guys.I am working on implementing the PL2 weighting scheme of the DFR framework by Gianni Amati. It uses the Poisson approximation of the Binomial as the probabilistic model (P), the Laplace law of succession to calculate the after effect of sampling or the risk gain (L) and within document frequency normalization H2(2) (as proposed by Amati in his PHD thesis). The formula for w(t,d) in
2007 Dec 14
1
Help! - boxcox transformations
Hi, Hope this does not sound too ignorant . I am trying to detrend and transform variables to achieve normality and stationarity (for time series use, namely spectral analysis). I am using the boxcox transformations. As my dataset contains zeros, I found I need to add a constant to it in order to run "boxcox". I have ran tests adding several types of constants, from .0001
2007 Sep 10
2
Are the error messages of ConstrOptim() consisten with each other?
Dear Friends. I found something very puzzling with constOptim(). When I change the parameters for ConstrOptim, the error messages do not seem to be consistent with each other: > constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible > constrOptim(c(0.5,0.9,0.5),
2000 Feb 02
1
No subject
Dear fellows, I'd like to perform a box-cox transformation to a data set and also plot lambda versus L(lambda) using R. Does anybody knows how can I do such a thing? Greetings to all, Adriane -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help",