Displaying 1 result from an estimated 1 matches for "fakeobs".
Did you mean:
fakelb
2011 Dec 08
0
Fit initial time with modFit and modCost
...utput is a #data.frame
with "time" (1,2,...,10) and "M" (0,...,0,h,...,h)
makeframe <- function(Par){
with(as.list(c(Par)),{
t <- seq(1,10,by=1)
vec <- h*as.numeric(t>t0)
return(data.frame(time=t,M=vec))
})
}
#Let the "measurement" be (0,0,0,2,2,2,2,2,2,2)
fakeobs <- makeframe(c(t0=3,h=2))
#cost function provided by modCost
cost <- function(Par){
out <- makeframe(Par)
cost <- modCost(model=out,obs=fakeobs)
return(cost)
}
#Fit for best t0 and h value, initial guess t0=5.5, h=1.2
initial <- c(t0=5.5,h=1.2)
Fit <- modFit(f=cost,p=initial)
co...