Displaying 11 results from an estimated 11 matches for "objfun".
2005 Jul 19
2
Michaelis-menten equation
...dCpdt <- -(parms["Vm"]/parms["Vd"])*y[1]/(parms["Km"]+y[1])
list(dCpdt)}
Dose<-300
modfun <- function(time,Vm,Km,Vd) {
out <- lsoda(Dose/Vd,time,mm.model,parms=c(Vm=Vm,Km=Km,Vd=Vd),
rtol=1e-8,atol=1e-8)
out[,2] }
objfun <- function(par) {
out <- modfun(PKindex$time,par[1],par[2],par[3])
sum((PKindex$conc-out)^2) }
fit <- optim(c(10,1,80),objfun, method="Nelder-Mead)
print(fit$par)
[1] 10.0390733 0.1341544 34.9891829 #--Km=0.1341544,wrong value--
#-----wrong model definiens--------
#-----...
2003 Jul 18
3
question about formulating a nls optimization
Dear list,
I'm migrating a project from Matlab to R, and I'm
facing a relatively complicated problem for nls. My
objective function is below:
>> objFun <- function(yEx,xEx,tEx,gamma,theta,kappa){
yTh <- pdfDY(xEx,tEx,gamma,theta,kappa)
sum(log(yEx/yTh)^2)
}
The equation is yTh=P(xEx,tEx) + noise.
I collect my data in:
>> data <- data.frame(xEx,tEx,yEx)
And I do the nls:
aux <- nls( ~ objFun(yEx,xEx,tEx,gamma,theta...
2012 Nov 26
1
Help on function please
...200
Tinf <-0.5
defun<- function(time, y, parms) {
dCpdt <- -parms["kel"] * y[1]
list(dCpdt)
}
modfun <- function(time,kel, Vd) {
out <- lsoda(((Dose/Tinf)*(1/(kel*Vd)))*(1-exp(-kel*time)),c(0,time),defun,parms=c(kel=kel,Vd=Vd),rtol=1e-3,atol=1e-5)
out[-1,2]
}
objfun <- function(par) {
out <- modfun(PKindex$time, par[1], par[2])
gift <- which( PKindex$conc != 0 )
sum((PKindex$conc[gift]-out[gift])^2)
}
gen<-genoud(objfun,nvars=2,max=FALSE,pop.size=30,max.generations=100,wait.generations=100,starting.value=c(0.7,60),BFGS=FALSE,print.level...
2012 Mar 20
2
Constraint Linear regression
...lution by Emmanuel using
least squares. The method (with modification) is as follows -
Data1<- data.frame(y=y,x1=x1, x2=x2)
# The objective function : least squares.
e<-expression((y-(c1+c2*x1+c3*x2))^2)
foo<-deriv(e, name=c("c1","c2","c3"))
# Objective
objfun<-function(coefs, data) {
return(sum(eval(foo,env=c(as.list(coefs), as.list(data)))))
}
# Objective's gradient
objgrad<-function(coefs, data) {
return(apply(attr(eval(foo,env=c(as.list(coefs), as.list(data))),
"gradient"),2,sum))
}
D1.unbound<-optim(par=c(c1=0.5, c2=...
2008 May 08
1
R strucchange question -- robust regression
Is it possible to use some form of robust regression with the
breakpoints routine so that it is less sensitive to outliers?
--Rich
Richard Kittler
Advanced Micro Devices, Inc.
Sunnyvale, CA
2008 Oct 01
1
maximum likelihood with constraints in R
Hi R-experts,
There is lots of information about maximum likelihood estimation in R.
However, I didn't came across anything about maximum likelihood with constraints.
For example, estimation of parameters k(1) to k(20) with maximum likelihood, where sum(k(i)) = 0.
Is there any standard function in R that can do this, or is this something that I should set up myself?
Greetings,
Church
2012 Jun 15
0
Syntax for nls optimization function
...myFunction, method = c("L-BFGS-B"), lower =
parMin, upper = parMax,
control=list(trace=3,factr=iFactr,maxit=300),
parOpt=parOpt,parVal=parVal,objFun=iObjFun,dset=dHM1,whatPDM=whatPDMi)
Here "myFunction" is a function that provides the value of the sum of
squared error that is computed after a lot of computations. There are other
parameters and data (through a dataframe dHM1) that are supplied to
"myFunction" as given in las...
2009 Mar 29
4
Constrined dependent optimization.
I have an optimization question that I was hoping to get some suggestions on how best to go about sovling it. I would think there is probably a package that addresses this problem.
This is an ordering optimzation problem. Best to describe it with a simple example. Say I have 100 "bins" each with a ball in it numbered from 1 to 100. Each bin can only hold one ball. This optimization is
2002 Aug 29
8
lme() with known level-one variances
Greetings,
I have a meta-analysis problem in which I have fixed effects
regression coefficients (and estimated standard errors) from identical
models fit to different data sets. I would like to use these results
to create pooled estimated regression coefficients and estimated
standard errors for these pooled coefficients. In particular, I would
like to estimate the model
\beta_{i} = \mu +
2009 Jun 01
1
installing sn package
...lt;-expression((y-(c1+x1+c2*x2+c3*x3))^2) # Least squares (needs data
in env.)
>
> # Use expression form of deriv(), to allow easy evaluation in a
constructed
> # environment
>
> foo<-deriv(e, nam=c("c1","c2","c3"))
>
> # Objective
>
> objfun<-function(coefs, data) {
+ return(sum(eval(foo,env=c(as.list(coefs), as.list(data)))))
+ }
>
> # Objective's gradient
>
> objgrad<-function(coefs, data) {
+ return(apply(attr(eval(foo,env=c(as.list(coefs), as.list(data))),
+ "gradient"),2,s...
2009 Apr 01
0
回复: R-help Digest, Vol 73, Issue 32
...t the docs for method="SANN" (and
the examples), you'll see that SANN allows you to pass the
"gradient" argument (gr) as a custom function to provide the
candidate distribution. Here's an example:
N <- 10
xvec <- seq(0,1,length=N)
target <- rank((xvec-0.2)^2)
objfun <- function(x) {
sum((x-target)^2)/1e6
}
objfun(1:100)
swapfun <- function(x,N=10) {
loc <- sample(N,size=2,replace=FALSE)
tmp <- x[loc[1]]
x[loc[1]] <- x[loc[2]]
x[loc[2]] <- tmp
x
}
set.seed(1001)
opt1 <- optim(fn=objfun,
par=1:N,
gr...