Displaying 20 results from an estimated 25 matches for "plotit".
Did you mean:
plotid
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...*********************
> 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, length.out =
> 61), plotit = FALSE)
> b$x[which.max(b$y)] # best lambda
> }
>
>> lambdas <- apply(dd,2 , BoxCoxLambda)
> Error in NextMethod() : 'NextMethod' called from an anonymous function
>
> and, indeed, ?UseMethod says:
> "NextMethod should not be called except in met...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...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, length.out =
61), plotit = FALSE)
b$x[which.max(b$y)] # best lambda
}
> lambdas <- apply(dd,2 , BoxCoxLambda)
Error in NextMethod() : 'NextMethod' called from an anonymous function
and, indeed, ?UseMethod says:
"NextMethod should not be called except in methods called by UseMethod
or from interna...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...ithout 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
> mcol <- 2
> set.seed(12345)
> dd <- matrix(rgamma(mrow*mcol, shape = 2, scale = 5), nrow = mrow, ncol =
+ mcol)
> dd1 <- dd[, 1] # 1st column of dd
> res <- boxcox(lm(dd1 + 1 ~ 1), lambda =...
2004 May 05
4
Discontinuities in a simple graph (machine precision?)
...mple function:
mdevstdev <- function(a){
l <- dnorm(a)/(1-pnorm(a))
integrand <- function(z)(abs(z-l)*dnorm(z))
inted <- integrate(integrand, a, Inf)
inted[[1]]/((1- pnorm(a))*sqrt((1 + a*l - l^2)))
}
I wanted to quickly produce a graph of this over the range [-3,3] so I
used:
plotit <-function(x=seq(-3,3,0.01),...){
y<-sapply(x,mdevstdev)
plot(x,y,...)
}
> plotit()
This produces the graph, but some discontinuities appear on it. I've
produced the same graph in Mathematica 5
(http://econserv2.bess.tcd.ie/cullens/R/DOverDelta.eps), and it was smooth
over th...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...ore 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:
>
> 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 'y' here ex...
2011 Mar 23
3
Sweave: multiple graphic formats, e.g. win.metafile
...g accustomed to the Microsoft Office Suite, I was looking for a way to have the RweaveLatex driver for Sweave automatically generating 'win.metafile's in addition to the pdf graphics.
Without this functionalilty, the generation of emf-graphics is quite laborious, I think:
<<>>=
plotit <- function () {
# code which generates the graphic
}
win.metafile("foobar.emf")
plotit()
dev.off()
pdf("foobar.pdf")
plotit()
dev.off()
@
\includegraphics{foobar}
I would like to have something like:
<<foobar, fig=true, pdf=true, emf=true>>
# code which gen...
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 'y' here explicitly in the
BoxCoxLambda envir...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...n error (see the reprex below).
I'm sure I'm doing something silly, but I can't see what it is. Any help appreciated.
library(MASS)
# Find optimised Lambda for Boc-Cox transformation
BoxCoxLambda <- function(z){
b <- boxcox(lm(z+1 ~ 1), lambda = seq(-5, 5, length.out = 61), plotit = FALSE)
b$x[which.max(b$y)] # best lambda
}
mrow <- 500
mcol <- 2
set.seed(12345)
dd <- matrix(rgamma(mrow*mcol, shape = 2, scale = 5), nrow = mrow, ncol = mcol)
# Try it not using the BoxCoxLambda function:
dd1 <- dd[,1] # 1st column of dd
bb <- boxcox(lm(dd1+1 ~ 1), lambd...
2005 Aug 31
2
R CMD check example problem (PR#8113)
...tered an error
in how R CMD check is extracting the example code I have in the .Rd file.
The example section contains the lines
# An equivalent function is somewhat messier, since it must either
explicitly
# construct the y axis label, duplicating some of the work of the plot
# function:
plotit <- function( df, var, col="red", title="" )
{
dname <- deparse(substitute(df))
vname <- deparse(substitute(var))
plot( df[[vname]] ~ df$Grp, type="b", col=col, title=title,
ylab=paste( dname, "$", vname, sep=''...
2007 May 12
0
There might be something wrong with cv.lm(DAAG)
...tor variable. But the usage documentation
hasn't informed us about this.
You can find it by excuting the following code:
xx=matrix(rnorm(20*3),ncol=3)
bb=c(1,2,0)
yy=xx%*%bb+rnorm(20,0,10)
data=data.frame(y=yy,x=xx)
myformula=formula("y ~ x.1 + x.2 + x.3")
cv.lm(data,myformula,m=10,plotit=F, printit=TRUE)
myformula=formula("y ~ x.1 + x.2")
cv.lm(data,myformula,m=10,plotit=F, printit=TRUE)
myformula=formula("y ~ x.1 ")
cv.lm(data,myformula,m=10,plotit=F, printit=TRUE)
What happened? they give three equal mss(mean squared error).
Or you can just check the code of...
2011 Feb 24
1
extract printed value from a function
Hello all,
This shouldn't be difficult, but I am not able to extract a printed
value from a function and assign it to an object.
In my case,
> library(DAAG)
> twotPermutation(c(2,3,4),c(3,6,5),plotit=F)
[1] 0.298
I would like to assign this result to an object.
Thanks,
Duarte
2013 Feb 15
0
CVlim
Can anyone help explain to me why the two codes below have different result? I thought I can use log(time)~. to replace log(time)~dist+climb+timef.I am using CVlm from DAAG package. I think nihills is preloaded with the package. Thanks in advance.
> CVlm(df=nihills, form.lm=formula(log(time)~.),plotit="Observed",m=2)Analysis of Variance Table
Response: log(time) Df Sum Sq Mean Sq F value Pr(>F) dist 1 6.34 6.34 384.31 4.6e-14 ***climb 1 0.12 0.12 7.24 0.0145 * timef 1 0.19 0.19 11.29 0.0033 ** Residuals 19 0.31 0.02...
2007 Feb 16
2
R implementations of scatterplot/map labeling algorithims?
...liography I've
found is
the Map-Labeling Bibliography,
http://liinwww.ira.uka.de/bibliography/Theory/map.labeling.html
AFAIK, the only concrete and published implementation is a Fortran
program published by Noma (below), and then adapted by Warren Kuhfeld
at SAS in PROC PLOT, and used in his %plotit macro.
Journal Title - Psychometrika
Article Title - Heuristic method for label placement in scatterplots
Volume - Volume 52
Issue - 3
First Page - 463
Last Page - 468
Issue Cover Date - 1987-09-27
Author - Elliot Noma
DOI - 10.1007/BF02294366...
2007 May 21
0
Is this a bug in cv.lm(DAAG) ?
...tation
hasn't informed us about this.
The code illustrates my discovery:
> library(DAAG)
> xx=matrix(rnorm(20*3),ncol=3)
> bb=c(1,2,0)
> yy=xx%*%bb+rnorm(20,0,10)
>
> data=data.frame(y=yy,x=xx)
> myformula=formula("y ~ x.1 + x.2 + x.3")
> cv.lm(data,myformula,plotit=F, printit=TRUE)
Analysis of Variance Table
Response: yv
Df Sum Sq Mean Sq F value Pr(>F)
xv 1 37 37 0.29 0.6
Residuals 18 2288 127
fold 1
Observations in test set: 4 6 7 9 10 19
X1 X2 X3 X4 X5 X6
x.1 -0.0316...
2011 Mar 04
4
cv.lm syntax error
Dear all,
I've tried a multiple regression, and now I want to try a cross-validation.
I obtain this error (it must be sth related to df) that I don't understand,
any help would be appreciated.
cv.lm(df= dat, lm2.52f, m=3)
Error en `[.data.frame`(df, , ynam) : undefined columns selected
lm2.52f is my lm object, dat is a dataframe where the variables involved in
.lm are
I tried CVlm
2011 Aug 08
0
Odp: Fw: R function for Gage R&R
...k is sample analysed - expected a factor, but is ok if numeric or
character vector
vysledek is a result of analysis - expected numeric vector
sigma is some coefficient
DM is lower limit, HM is upper limit, toler is range either computed from
DM and HM or set by you - addon from mentioned textbook
plotit is switch for enabling or disabling plot function - expected
logical value
dig is number of digits for rounding result
The function is based on anova
Here is an example
test<-expand.grid(operator=letters[1:4],vzorek=LETTERS[5:8])
test<-sapply(test,rep,4)
test<-as.data.frame(test)
s...
2011 Mar 26
0
rebuilding vignettes in 2.13-0-alpha fails if name of source dir is not package name
...rcurve
Code: function(X, method = c("ca", "pca", "random"), smoother =
smoothSpline, complexity, vary = FALSE, maxComp,
finalCV = FALSE, axis = 1, rank = FALSE, stretch = 2,
maxit = 10, trace = FALSE, thresh = 0.001, plotit =
FALSE, fitFUN = c("princurve", "pcurve"), latent =
FALSE, ...)
Docs: function(X, method = c("ca", "pca", "random"), smoother =
smoothSpline, complexity, vary = FALSE, maxComp,
f...
2008 Jun 05
1
choosing an appropriate linear model
...ed line")
abline(leach.lm)
plot(predict(leach.lm)~leachdata$leachate,main="predicted vs. observed
leaching amount",xlim=c(0,12),ylim=c(0,12),xlab="observed
leaching",ylab="predicted leaching")
abline(a=0,b=1)
plot(leach.lm)
dev.off()
library(MASS)
boxcox(leach.lm,plotit=T,lambda=seq(0,0.4,by=0.01))
boxtran <- function(y,lambda,inverse=F){
if(inverse)
return((lambda*y+1)^(1/lambda))
else
return((y^lambda-1)/lambda)
}
png("boxcox-dianostics.png",height=1200,width=700)
par(mfrow=c(3,2))
logleach.lm <- lm(boxtran(leachate,0.21)~rainmm-1,d...
2003 Jan 22
2
small bug in binom.test?
Hi all,
I am wondering whether there is a small bug in the binom.test function of
the ctest library (I'm using R 1.6.0 on windows 2000, but Splus 2000 seems
to have the same behaviour). Or perhaps I've misunderstood something.
the command binom.test(11,100,p=0.1) and binom.test(9,100,p=0.1) give
different p-values (see below). As 9 and 11 are equidistant from 10, the
mean of the
2004 Jun 28
1
plotting with an its object
Dear R People:
I have an its object. The original its is the Dow Jones Industrial average
from March 23, 1990 to March 23, 2000. I did the following;
dj1 = original series
>dj2 <- log(dj1)
>ddj2 <- diff(dj2)
>
Ok so far.
Now I would like to plot this series with a certain y limit:
>min(ddj2)
[1] -0.07454905
>max(ddj2)
[1] 0.04860535
>plot(ddj2,ylim=c(-0.1,0.1))
Error