Displaying 16 results from an estimated 16 matches for "xhat".
Did you mean:
that
2019 Feb 01
3
nlminb with constraints failing on some platforms
Hello,
R 3.5.2 on ubuntu 18.04. sessionInfo() at the end.
Works with me, same results, cannot reproduce the error.
f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
str(opt)
xhat <- rep(1, 10)
all.equal(opt$par, xhat, tol=0) # good: 5.53 e-7
#[1] "Mean relative difference: 5.534757e-07"
all.equal(opt$objective, f(xhat), tol=0) # good: 1.8 e-12
#[1] "Mean relative difference: 1.816536e-12"
abs( opt$objective - f(xhat) ) < 1e-4 ## Must be T...
2019 Jan 28
8
nlminb with constraints failing on some platforms
I've noticed unstable behavior of nlminb on some Linux systems. The problem can be reproduced by compiling R-3.5.2 using gcc-8.2 and running the following snippet:
f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
xhat <- rep(1, 10)
abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE
The example works perfectly when removing the bounds. However, when bounds are added the snippet returns 'FALSE'.
An older R version (3.4.4), compiled using the same gcc-8.2, did not have the problem. Between the t...
2019 Feb 01
0
nlminb with constraints failing on some platforms
...$ par : num [1:10] 1 1 1 1 1 ...
$ objective : num -41.4
$ convergence: int 0
$ iterations : int 66
$ evaluations: Named int [1:2] 96 830
..- attr(*, "names")= chr [1:2] "function" "gradient"
$ message : chr "relative convergence (4)"
> xhat <- rep(1, 10)
> all.equal(opt$par, xhat, tol=0)
[1] "Mean relative difference: 3.266165e-07"
> all.equal(opt$objective, f(xhat), tol=0)
[1] "Mean relative difference: 6.722005e-13"
> abs( opt$objective - f(xhat) ) < 1e-4
[1] TRUE
> sessionInfo()
R ver...
2019 Feb 01
1
nlminb with constraints failing on some platforms
...or BLAS/LAPACK ..
>
> I also use gcc 8.2 (on Fedora 28 Linux) and R's own BLAS/LAPACK
> and don't see such problems:
>
> The code
>
> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
> str(opt)
> xhat <- rep(1, 10)
> all.equal(opt$par, xhat, tol=0) # good: 5.53 e-7
> all.equal(opt$objective, f(xhat), tol=0) # good: 1.8 e-12
> abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE
>
> gives
>
>> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
&g...
2006 Sep 11
2
faster way?
Hi,
Is there a faster way to do this? It takes forever, even on a
moderately sized dataset.
n <- dim(dsn)[1]
dsn2 <- dsn[order(-dsn$xhat),]
dsn2[1, "cumx"] <- dsn2[1, "xhat"]
for (i in 2:n) {
dsn2[i, "cumx"] <- dsn2[i - 1, "cumx"] + dsn2[i, "xhat"]
}
[[alternative HTML version deleted]]
2019 Feb 01
0
nlminb with constraints failing on some platforms
...e behavior of nlminb on some Linux
> systems. The problem can be reproduced by compiling
> R-3.5.2 using gcc-8.2 and running the following snippet:
> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
> xhat <- rep(1, 10)
> abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE
> The example works perfectly when removing the bounds. However, when bounds are added the snippet returns 'FALSE'.
> An older R version (3.4.4), compiled using the same gcc-8.2, did not have...
2017 Nov 07
2
Using MLE on a somewhat unusual likelihood function
...utine dgesv: system is exactly singular: U[1,1] = 0
This error sometimes indicates that the list of starting values is too far
from optimum but this is unlikely since I picked values close to where the
parameters usually end up. I have also tried switching these around a bit.
Here is the code:
xhat = c(statemw-(1-alpha)*rval)
survivalf <- function(x) {(1-plnorm(statemw,mean=mu,sd=logalpha))}
wagefn <- function(lam, eta, alpha, xhat, mu, logalpha) {
n=nrow(cpsdata2)
wagevec = matrix(nrow=n,ncol=1)
for (i in 1:n) {
if (cpsdata2[i,2] > 0){
wagevec[i,] <-
c(eta*l...
2019 Jan 31
1
nlminb with constraints failing on some platforms
...e R-forge (developmental) version of the optimx package at
> https://r-forge.r-project.org/projects/optimizer/
>
> I used the code
>
> ## KKristensen19nlminb.R
> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
> xhat <- rep(1, 10)
> abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE
> opt
> library(optimx)
> optx <- opm(rep(0,10), f, lower=-1, upper=3, method="ALL")
> summary(optx, order=value)
> optxc <- opm(rep(0,10), f, gr="grcentral", lower=-1, upper=3,...
2019 Feb 04
2
nlminb with constraints failing on some platforms
I get the failure message. To be specific:
adcomp.git>R CMD BATCH --quiet test_nlminb.R
adcomp.git>cat test_nlminb.Rout
> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
> xhat <- rep(1, 10)
> abs( opt$objective - f(xhat) ) < 1e-4? ## Must be TRUE
[1] FALSE
My system is described by:
adcomp.git>uname -a
Linux localhost.localdomain 4.17.7-200.fc28.x86_64 #1 SMP Tue Jul 17 16:28:31 UTC 2018 x86_64 x86_64
x86_64 GNU/Linux
My version of R is described by:
Sour...
2019 Feb 06
0
nlminb with constraints failing on some platforms
...es:
> I get the failure message. To be specific:
adcomp.git> R CMD BATCH --quiet test_nlminb.R
adcomp.git> cat test_nlminb.Rout
>> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
>> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
>> xhat <- rep(1, 10)
>> abs( opt$objective - f(xhat) ) < 1e-4? ## Must be TRUE
> [1] FALSE
ok... [I gave a version of the above which reveals a bit more ...]
> My system is described by:
adcomp.git> uname -a
> Linux localhost.localdomain 4.17.7-200.fc28.x86_64...
2019 Jan 31
0
nlminb with constraints failing on some platforms
...r most optimizers at my
disposal in the R-forge (developmental) version of the optimx package at
https://r-forge.r-project.org/projects/optimizer/
I used the code
## KKristensen19nlminb.R
f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
xhat <- rep(1, 10)
abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE
opt
library(optimx)
optx <- opm(rep(0,10), f, lower=-1, upper=3, method="ALL")
summary(optx, order=value)
optxc <- opm(rep(0,10), f, gr="grcentral", lower=-1, upper=3, method="ALL")
summar...
2017 Nov 07
0
Using MLE on a somewhat unusual likelihood function
...: U[1,1] = 0
>
> This error sometimes indicates that the list of starting values is too far
> from optimum but this is unlikely since I picked values close to where the
> parameters usually end up. I have also tried switching these around a bit.
>
> Here is the code:
>
> xhat = c(statemw-(1-alpha)*rval)
> survivalf <- function(x) {(1-plnorm(statemw,mean=mu,sd=logalpha))}
>
> wagefn <- function(lam, eta, alpha, xhat, mu, logalpha) {
> n=nrow(cpsdata2)
> wagevec = matrix(nrow=n,ncol=1)
> for (i in 1:n) {
>
> if (cpsdata2[i,2] >...
2007 Feb 17
1
Solve in maximum likelihood estimation
...<- matrix(ncol=no.obs,nrow=no.obs)
Ffast <- matrix(ncol=no.obs,nrow=no.obs)
P <- Pminus <- array(dim=c(no.state,no.state,n))
Pfast <- Pfastmin <- matrix(NA,ncol=no.state,nrow=no.state)
K <- array(dim=c(no.state,no.obs,n))
Kfast <- matrix(nrow=no.state,ncol=no.obs)
X <- Xhatminus <- array(dim=c(no.state,1,n))
Xfast <- Xfastmin <- matrix(ncol=1,nrow=no.state)
v <- array(dim=c(no.obs,1,n))
vfast <- matrix(nrow=no.obs,ncol=1)
Y <- matrix(ncol=1,nrow=no.obs)
log.lik <- numeric(n)
Rprof()
kalman <- function(a)...
2007 Oct 23
1
Compute R2 and Q2 in PLS with pls.pcr package
...sure if the values of Ypred within the validat slot are
the predictions of each observation of Y when leave-one-out cross
validation is applied.
My code is as follows:
> mypls <- mvr(Xtrain, Ytrain, method="SIMPLS", validation="CV",
ncomp=1, niter=nrow(Ytrain))
> Xhat <- mypls$training$Xscores %*% t(mypls$training$Xload)
> R2 <- 1-(sum((Xhat-Xtrain)^2)/sum(Xtrain^2))
> Q2 <- 1-(sum((Ytrain-mypls$validat$Ypred[,,1])^2)/sum(Ytrain^2)
Is this right?
Thank you
Ana
-------------------------------------------
Ana Conesa, PhD
Bioinformatics Depa...
2002 Apr 24
3
nonlinear least squares, multiresponse
I'm trying to fit a model to solve a biological problem.
There are multiple independent variables, and also there are multiple
responses.
Each response is a function of all the independent variables, plus a set of
parameters. All the responses depend on the same variables and parameters -
just the form of the function changes to define each seperate response.
Any ideas how I can fit
2013 Feb 05
1
R -HELP REQUEST
Good morning to you all,
Sorry for taking your time from your research and
teaching schedules.
If you have a non-stationary univariate time Series
data that has the transformation:
Say; l.dat<-log (series)
d.ldat<-diff (l.dat, differences=1)
and you fit say arima model.
predit.arima<-predict (fit.series, n.ahead=10,
xregnew= (n+1) :( n+10))
How could I re-transform