Displaying 20 results from an estimated 7310 matches for "formula".
2000 Oct 12
2
works in R-1.1.1 but not in R-development; why?
...e
name of the data frame for extracting weights or subsets within a function
call. The problems can be reproduced as follows:
**********************
datai <- data.frame( y = rnorm(10), x1 = rnorm(10), x2 = abs(rnorm(10)),
x3 = rep(seq(1,5),2), counter = rep(c(1,2),c(5,5)))
formula <- as.formula(y ~ x1)
# the following fails in R-1.2.0 but not in R-1.1.1
# > Error in eval(expr, envir, enclos) : Object "datos" not found
lapply(split(datai,datai$counter),
function(datos,formula) {lm(formula = formula, data = datos,
wei...
2006 Jun 13
2
levelplot and source() problems
...r below,
it's very much like what went on in the more complex example.
best
Niels
Debugging levelplot:
> library(lattice)
> debug(levelplot)
> source("lptest.r")
[1] "test"
debugging in: levelplot(matrix(11:14, 2, 2))
debug: {
ocall <- match.call()
formula <- ocall$formula
if (!is.null(formula)) {
warning("The 'formula' argument has been renamed to 'x'. See
?xyplot")
ocall$formula <- NULL
if (!("x" %in% names(ocall)))
ocall$x <- formula
else warning("...
2008 Dec 26
3
lm() with same formula but different column/factor combinations in data frame
...****************************************************************************************
I need to store the coefficients using lm() for different combinations
of the 4 factors, or different combinations of 3 factors or different
combinations of 2 factors or
differennt combinations of 1 factor.
The formula remains fixed as:
> Formula
UncDmd ~ M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10 + M11
So, different models I want to solve in R are :
1) Community : lm(Formula,TEST1[ as.logical(
(TEST1[[1]]=="20232") ) , ])
2) WT : lm(Formula,TEST...
2011 Jul 13
1
question on formula and terms.formula()
I'm trying to create a formula object to pass on to a function that
applies the function terms.formula() to it.
f <- function(formula, ...)
{
...
mf <- match.call()
term <- terms.formula(mf$formula)
...
}
However, my code below gives an error.
form <- as.formula("y~x")
f(form, ...)
The error message w...
2008 May 30
2
scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)
I've run into a scoping problem in R.
I'm calling a function that
* creates a formula
* calculates a weight vector
* calls lm with that formula and weights
This fails.
Here's a simplified reproduce example:
# f works, g doesn't, h is a workaround
rm(w)
data <- data.frame(y=runif(20), x=runif(20), z=runif(20))
f <- function(k){
w <- data$z^k
coef(lm(y~x, d...
2017 Aug 23
3
boot.stepAIC fails with computed formula
Until I get a fix that works, a work-around would be to rename the 'y1' column, used a fixed formula, and rename it back afterwards.
Thanks for your help.
SGO.
-----Original Message-----
From: Bert Gunter [mailto:bgunter.4567 at gmail.com]
Sent: 22 August 2017 20:38
To: Stephen O'hagan <SOhagan at manchester.ac.uk>
Cc: r-help at r-project.org
Subject: Re: [R] boot.stepAIC fails with c...
2017 May 23
0
Allow dot in RHS of update.formula's old formula
Feature request:
I want to use update.formula to subtract an intercept (or other) term from a formula with a dot on the RHS. However, as this causes an error, I propose a patch below.
Thus, I want:
> update.formula(y ~ ., ~ . -1)
[1] y ~ . - 1
Instead I get this error:
Error in terms.formula(tmp, simplify = TRUE) :
'.' in formu...
2007 Oct 01
4
Disentagling formulas
I am writing a program in which I would like to take in a formula, change the response (Y) variable into something else, and then pass the formula, with the new Y variable to another function. That is, I am starting with
formula <- Y~X1+X2+X3
and I'd like to do something like
Y <- formula$Y
newY <- f(Y)
lm(newY~X...
2013 May 17
2
How could I see the source code of functions in an R package?
...x, data, ...)
UseMethod("xyplot")
<environment: namespace:lattice>
> library(plm)
Loading required package: bdsmatrix
Attaching package: ‘bdsmatrix’
The following object(s) are masked from ‘package:base’:
backsolve
Loading required package: nlme
Loading required package: Formula
Loading required package: MASS
Loading required package: sandwich
Loading required package: zoo
Attaching package: ‘zoo’
The following object(s) are masked from ‘package:base’:
as.Date, as.Date.numeric
> ?plm
> plm
function (formula, data, subset, na.action, effect = c("individua...
2017 Aug 23
0
boot.stepAIC fails with computed formula
It seems that if you build the formula as a character string, and
postpone the "as.formula" into the lm call, it works.
instead of
frm1 <- as.formula(paste(trg,"~1"))
use
frm1a <- paste(trg,"~1")
and then
strt <- lm(as.formula(frm1a),dat)
regards,
Heinz
Stephen O'hagan wrote/hat geschriebe...
2007 Jul 16
5
formula(CO2)
The formula attribute of the builtin CO2 dataset seems a bit strange:
> formula(CO2)
Plant ~ Type + Treatment + conc + uptake
What is one supposed to do with that? Certainly its not suitable for
input to lm and none of the examples in ?CO2 use the above.
2004 May 25
3
problems with plot.formula
With the recent changes in R 1.9.x, it is now impossible to properly call
plot on a formula() where the formula is provided via a named first
argument. On today's R-1.9.1-alpha:
> x <- 1:10
> y <- rnorm(x,0.25)
>
> plot(x~y)
>
> plot(x=x~y)
Error in terms.formula(formula, data = data) :
argument is not a valid model
>
> plot(formula=x~y)
Error in p...
2004 Jul 15
5
formula
Hi, i 'dont understand how to take a general formula, view this:
x<-1:5
y<-c(0,1,1.7,2,2.1.4)
dummy<-data.frame(x=x,y=y)
formula<-"y~A*log(x)/log(2)"
formu<-as.formula(formula)
fm<-lm(formu,data=dummy)
Error in eval(expr, envir, enclos) : Object "A" not found
but A is the parameter of fitting, why is this?Than...
2010 Jul 06
4
Assign Formulas to Arrays or Matrices?
Hi,
I am very new to R. I am hoping to create formulas and assign them to
locations within an array (or matrix, if it will work).
Here's a simplified example of what I'm trying to do:
form.arr <- array(31,5,3)
for (i in seq(from=1, to=31, by=1)) {
for (j in seq(from=1, to=5, by=1)) {
form.arr[i,j,] <- as.formula(y~1+2)
}
}
which r...
2011 Nov 24
2
proper work-flow with 'formula' objects and lm()
Dear all
I have a work-flow issue with lm(). When I use
> lm(y1~x1, anscombe)
Call:
lm(formula = y1 ~ x1, data = anscombe)
Coefficients:
(Intercept) x1
3.0001 0.5001
I get as expected the formula, "y1 ~ x1", in the print()ed results or
summary(). However, if I pass through a formula object
> (form <- formula(y1~x1))
y1 ~ x1
> lm(form, anscombe)
Cal...
2024 Nov 01
1
Invalid term in model formula with gmm after formula.tools is loaded
...art
automatically generated by your mailer, which isn't always readable.
? Wed, 30 Oct 2024 17:45:29 +0100
Elys?e Aristide <ariel92and at gmail.com> ?????:
> I am using the gmm function from the gmm package and encountered an
> unexpected error. No model can be estimated if I load formula.tools?I
> need to restart R each time.
I can reproduce the problem:
library(gmm)
data(Finance)
r <- Finance[1:300, 1:10]
rm <- Finance[1:300, "rm"]
rf <- Finance[1:300, "rf"]
z <- as.matr...
2007 Jan 09
5
a question of substitute
Hi all,
I want to write a wrapper for an analysis of variance and I face a curious
problem. Here are two different wrappers:
fun.1 <- function(formula) {
summary(aov(formula))
}
fun.2 <- function(formula) {
oneway.test(formula)
}
values <- c(15, 8, 17, 7, 26, 12, 8, 11, 16, 9, 16,
24, 20, 19, 9, 17, 11, 8, 15, 6, 14)
group <- rep(1:3, each=7)
# While the first wrapper works just fine:
fun.1(values ~ group)
# the s...
2011 Jan 07
1
formula(model.frame(y~.^2, data=d)) does not return formula from terms attribute of the model.frame
In R 2.12.0 I get
> d <- data.frame(x=1:10, y=log(1:10), f3=LETTERS[rep(1:3,c(3,3,4))])
> m <- model.frame(y~.^2, data=d)
> formula(m)
y ~ x + f3
In S+ formula(m) gives formula given to model.frame(),
but in R you have to do the following get that formula:
> formula(attr(m, "terms"))
y ~ (x + f3)^2
Would it break anything to add to the top of formula.data.frame
something like
if (!is.null(tms <- attr(x,...
2024 Oct 30
1
Invalid term in model formula with gmm after formula.tools is loaded
Hi everyone,
I am using the gmm function from the gmm package and encountered an
unexpected error. No model can be estimated if I load formula.tools?I need
to restart R each time. Here is a simple reproducible example:
*library(gmm)data(Finance)r <- Finance[1:300, 1:10]rm <- Finance[1:300,
"rm"]rf <- Finance[1:300, "rf"]z <- as.matrix(r-rf)zm <- rm-rfres <- gmm(z
~ zm, x = ~ zm)summa...
2009 Jul 30
3
update.formula and backticked colons
I just noticed the following in update.formula and I'm wondering if
this behavior is the intention of the developers. Here's an example:
update(`a: b` ~ x, ~ . + y)
Note now that the response has no backticks and is interpreted as a:b
(i.e. ":" is now an operator). This is because in update.formula the
call to terms.formula...