Displaying 20 results from an estimated 1000 matches similar to: "Potential bug in fitted.nls"
2023 Jan 26
1
Potential bug in fitted.nls
Doesn't nls() expect that the lengths of vectors on both sides of the
formula match (if both are supplied)? Perhaps it should check for that.
-Bill
On Thu, Jan 26, 2023 at 12:17 AM Dave Armstrong <darmst46 at uwo.ca> wrote:
> Dear Colleagues,
>
> I recently answered [this question]() on StackOverflow that identified
> what seems to be unusual behaviour with
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
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
2015 Oct 13
1
A where() functions that does what exists() does but return the environment when object lives?
On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> Seems easy enough to write yourself:
>
> where <- function(x, env = parent.frame()) {
> if (identical(env, emptyenv()))
> return(NULL)
> if (exists(x, envir = env, inherits = FALSE))
> return(env)
> where(x, parent.env(env))
> }
>
> sample2 <-
2019 Jan 21
1
Request: make `var` a generic
Hi all,
I am running into problems using `summary.lm` as calling `var` on a `units`
object does not retain the `units` attribute.
The units package addresses this issue for `mean` by implementing
`mean.units`:
units:::mean.units
function (x, ...)
{
.as.units(NextMethod(), units(x))
}
This is, however, not possible for `var` (as it's not a generic), which
breaks `summary.lm`:
```
2019 Sep 20
2
ggplot con gradientes complejos
Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
el mapa corregirlo para que indique los valores reales. Eso funcionaría,
pero son muchos mapas y quizás haya una función en ggplot que evite el
problema directamente.
Manuel
El
2019 Sep 20
2
ggplot con gradientes complejos
No sé muy bien, Carlos, como hacerlo, pero no parece más sencillo que lo de
multiplicar por 2 los positivos y después editar el mapa.
De lo que decías, Emilio, de cambiar el color del punto central creo que
haría más confusa la interpretación.
El vie., 20 sept. 2019 a las 10:33, Carlos Ortega (<cof en qualityexcellence.es>)
escribió:
> Hola,
>
> Una alternativa que suele
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:
>
>
2017 Nov 26
0
dplyr - add/expand rows
To David W.'s point about lack of a suitable reprex ("reproducible
example"), Bill's solution seems to be for only one station.
Here is a reprex and modification that I think does what was requested for
multiple stations, again using base R and data frames, not dplyr and
tibbles.
First the reprex with **two** stations:
> d <- data.frame( station =
2023 Nov 04
1
Adding columns to a tibble based on a value in a different tibble
I think a simple reproducible example ("reprex") may be necessary for you
to get a useful reply. Questions with vague specifications such as yours
often result in going round and round with attempts to clarify what you
mean without a satisfactory answer. Clarification at the outset with a
reprex may save you and others a lot of frustration.
Cheers,
Bert
On Sat, Nov 4, 2023 at 1:41?AM
2017 Nov 28
1
dplyr - add/expand rows
Bert wrote
... Bill's solution seems to be for only one station.
No, it works for any number of stations.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sun, Nov 26, 2017 at 11:10 AM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:
> To David W.'s point about lack of a suitable reprex ("reproducible
> example"), Bill's solution seems to be for only one
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
2018 Apr 18
3
Understanding which
Dear All,
Here is a reprex:
> x<- 1:100
> x[-which(x>100)]
integer(0)
In words, I am finding out which indices correspond to values in x which
are greater than 100 ( there are no such items ) . Then I remove those
indices. I should get back the x that I started with since there are no
items in x which are bigger than 100 . Instead, it is returning an empty
vector.
Why is this ?
2017 Nov 27
2
dplyr - add/expand rows
try this:
##########################################
library(dplyr)
input <- tribble(
~station, ~from, ~to, ~record,
"07EA001" , 1960 , 1960 , "QMS",
"07EA001" , 1961 , 1970 , "QMC",
"07EA001" , 1971 , 1971 , "QMM",
"07EA001" , 1972 , 1976 , "QMC",
"07EA001" , 1977 ,
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
2019 Apr 30
2
Background R session on Unix and SIGINT
Hi All,
I realize that this is not a really nice reprex, but anyone has an
idea why a background R session would "remember" an interrupt (SIGINT)
on Unix?
rs <- callr::r_session$new()
rs$interrupt() # just sends a SIGINT
#> [1] TRUE
rs$run(function() 1+1)
#> Error: interrupt
rs$run(function() 1+1)
#> [1] 2
It seems that the main loop somehow stores the SIGINT it
2018 May 09
2
NAs produced by integer overflow, but only some time ...
Before responding to Jeff's posting, let me reiterate my question: Why
does a function using m1*m1 produce an integer overflow, but m1^2 does
not?
As for Jeff's 'response':
> a) Numeric values may be either integers (signed 32 bit) or double precision (53 bit mantissa).
> b) Double precision constants are numeric with no decoration (e.g. 61224). Integer constants have an L
2018 May 09
0
NAs produced by integer overflow, but only some time ...
a) Numeric values may be either integers (signed 32 bit) or double precision (53 bit mantissa).
b) Double precision constants are numeric with no decoration (e.g. 61224). Integer constants have an L (e.g. 61224L).
c) 61224*61224 > 2^31-1 so that answer cannot fit into an integer.
d) Exponentiation is a floating point operation so the result of 61224L^2L is a floating point answer that CAN
2017 Nov 28
0
dplyr - add/expand rows
On 11/26/2017 08:42 PM, jim holtman wrote:
> try this:
>
> ##########################################
>
> library(dplyr)
>
> input <- tribble(
> ~station, ~from, ~to, ~record,
> "07EA001" , 1960 , 1960 , "QMS",
> "07EA001" , 1961 , 1970 , "QMC",
> "07EA001" , 1971 , 1971 ,