rss {nanop} | R Documentation |
Given a nanoparticle model and PDF or total scattering structure function data, this function calculates the PDF or total scattering structure function associated with the model. It then determines the residual sum of squares (RSS) between the PDF or total scattering structure function and the data.
rss(par, data, avRes, dataType="PDF", simPP=NA, simPar=NA, PDF.fixed=NA, TotalScatt.fixed=NA, verbose, parscale=NA, skel=NA, con=TRUE, punish=FALSE, avResrcenter=FALSE, analBroad=FALSE)
par |
A numeric vector of parameter values. These should be given along
with the appropriate arguement skel . See the examples for
details.
|
data |
A numeric vector of PDF or total scattering structure function data. |
avRes |
A numeric value; if the model for the data is stochastic, this is the number of particles to simulate; the model PDF or total scattering structure function is calculated for each particle and then averaged. |
dataType |
Either "PDF" if data represent PDF data or
"TotalScatt" if data represent total scattering
structure function data.
|
simPP |
Either NA or
the atomic positions in a nanoparticle given as a numeric
matrix in which each row gives the (3D) position coordinates. A
matrix of this form is the return value of the function
simPart . Default value of NA means that the
particle is to be re-simulated each call to rss
(necessary for stochastic model functions).
|
simPar |
Arguments are passed to the function
simPart to simulate the nanoparticles if these values
are not to be optimized; any of the
following arguments may be specified: latticep ,
latticepshell , sym , rcenter .
|
PDF.fixed |
Arguments are passed to the function
calcPDF ; any of the
following arguments may be specified: calpha ,
dr , minR , maxR , p . |
TotalScatt.fixed |
Arguments are passed to the function
calcTotalScatt ; any of the
following arguments may be specified: dQ ,
minQ , maxQ , a1 , b1 ,
a2 , b2 ,a3 , b3 ,
a4 , b4 , c . |
verbose |
Logical indicating whether to print information. |
parscale |
Either NA or a numeric
vector of the same length as par indicating values by which
the values in par should be divided for the purpose of
parameter scaling.
|
skel |
an object of class relistable . First the
parameters to be optimized should be written as a named list of
form parameters <-list(a=1,b=2,c=3) .
Then the argument par can
be given as par=unlist(parameters) and skel can be
given as skel=as.relistable(parameters) . |
con |
Logical indicating whether to reset
sigmashell to be equal to sigmacore if
sigmashell > sigmacore and to reset
r to be equal to rcore if
rcore > r . |
punish |
If the inequalities described above for con are
violated, return a large RSS value (10e15 ). |
avResrcenter |
Logical; if TRUE (which is possibly desirable
only if simPar$rcenter=TRUE )
then a new particle with a random center is
simulated each of avRes times. |
analBroad |
If TRUE then broadening to account for thermal
motion is accomplished analytically; if FALSE then it is
accomplished using the function displacePart . This option
only applies if dataType="PDF" ; if dataType="TotalScatt"
then link{displacePart} is always applied. |
A numeric value indicating the RSS.
a <- simPart() x <- calcPDF(a) xx1 <- broadPDF(x, sigma=.0125) ## plot PDF data plot(xx1$r,xx1$gr, type="l") ## in order to estimate the parameters that were used to ## simulate the particles, the DEoptim package may be ## used. Install it, remove the comment symbols '#' below, ## and use a call like: ##library(DEoptim) ##ax <- as.relistable(list(latticep=0,r=10,sigma=0)) ##res <- DEoptim(rss, ## lower=c(latticep=3.5, r=5.5,sigma=.001), ## upper=c(latticep=5.6, r=12,sigma=.1), ## control=DEoptim.control(NP=50, VTR=.5), ## data=xx1$gr, dataType="PDF", punish=TRUE, ## simPar = simPartPar(), ## PDF.fixed=PDFPar(), ## verbose=TRUE, skel=ax, ## analBroad=TRUE) ## now res$optim contains estimates for the particle radius, ## displacement variance sigma, and lattice parameter