# \dontshow{
require(geoR)
data("Missouri")
data=Missouri[1:70,]
data$V3=log((data$V3))
cc=data$V5
y=data$V3
n=127
k=1
datare1=data
coords=datare1[,1:2]
data1=data.frame(coords,y)
data1=data1[cc==0,]
geodata=as.geodata(data1,y.col=3,coords.col=1:2)
v=variog(geodata)
v1=variofit(v)
cov.ini=c(0,2)
est=SAEMSCL(cc,y,cens.type="left",trend="cte",coords=coords,M=15,perc=0.25,
MaxIter=1,pc=0.2,cov.model="exponential",fix.nugget=TRUE,nugget=2,
inits.sigmae=cov.ini[2],inits.phi=cov.ini[1], search=TRUE,lower=0.00001,upper=100)
w=localinfmeas(est,fix.nugget=TRUE,c=3)
res=w$respper
res[res[,1]=="atypical obs",]
sm=w$smper
sm[sm[,1]=="atypical obs",]
ev=w$expvper
ev[ev[,1]=="atypical obs",]
# }
# \donttest{
require(geoR)
data("Missouri")
data=Missouri
data$V3=log((data$V3))
cc=data$V5
y=data$V3
n=127
k=1
datare1=data
coords=datare1[,1:2]
data1=data.frame(coords,y)
data1=data1[cc==0,]
geodata=as.geodata(data1,y.col=3,coords.col=1:2)
v=variog(geodata)
v1=variofit(v)
cov.ini=c(0,2)
est=SAEMSCL(cc,y,cens.type="left",trend="cte",coords=coords,M=15,perc=0.25,
MaxIter=5,pc=0.2,cov.model="exponential",fix.nugget=TRUE,nugget=2,
inits.sigmae=cov.ini[2],inits.phi=cov.ini[1], search=TRUE,lower=0.00001,upper=100)
w=localinfmeas(est,fix.nugget=TRUE,c=3)
res=w$respper
res[res[,1]=="atypical obs",]
sm=w$smper
sm[sm[,1]=="atypical obs",]
ev=w$expvper
ev[ev[,1]=="atypical obs",]
##############ANOTHER EXAMPLE#########
n<-200 ### sample size for estimation
n1=100 ### number of observation used in the prediction
###simulated coordinates
r1=sample(seq(1,30,length=400),n+n1)
r2=sample(seq(1,30,length=400),n+n1)
coords=cbind(r1,r2)
coords1=coords[1:n,]
cov.ini=c(0.2,0.1)
type="exponential"
xtot=as.matrix(rep(1,(n+n1)))
xobs=xtot[1:n,]
beta=5
###simulated data
obj=rspacens(cov.pars=c(3,.3,0),beta=beta,x=xtot,coords=coords,cens=0.25,n=(n+n1),
n1=n1,cov.model=type,cens.type="left")
data2=obj$datare
cc=obj$cc
y=obj$datare[,3]
##### generating atypical observations###
y[91]=y[91]+4
y[126]=y[126]+4
y[162]=y[162]+4
coords=obj$datare[,1:2]
###initial values###
cov.ini=c(0.2,0.1)
est=SAEMSCL(cc,y,cens.type="left",trend="cte",coords=coords,M=15,perc=0.25,
MaxIter=10,pc=0.2,cov.model=type,fix.nugget=TRUE,nugget=0,inits.sigmae=cov.ini[1],
inits.phi=cov.ini[2],search=TRUE,lower=0.00001,upper=50)
w=localinfmeas(est,fix.nugget=TRUE,c=3)
res=w$respper
res[res[,1]=="atypical obs",]
sm=w$smper
sm[sm[,1]=="atypical obs",]
ev=w$expvper
ev[ev[,1]=="atypical obs",]
# }
Run the code above in your browser using DataLab