RandomFields/0000755000176200001440000000000013616730065012630 5ustar liggesusersRandomFields/NAMESPACE0000644000176200001440000001246013437301605014045 0ustar liggesusers####exportPattern("^[^\\.]") exportPattern("^RM") exportPattern("^RP") exportPattern("^RF") exportPattern("^RC") exportPattern("^RR") exportPattern("^R\\.") import("graphics") import("methods") import("grDevices") import("stats") import("utils") #importFrom('raster', raster, projection) #importFrom('colorspace', heat_hcl, rainbow_hcl) #importFrom('spam', as.spam, solve.spam, chol.spam) importClassesFrom('sp', # "CRS", "SpatialGridDataFrame", "SpatialPointsDataFrame", "SpatialGrid", "SpatialPixels", "SpatialPoints", "Spatial") importMethodsFrom("sp", "dimensions") #"gridded"gibts nicht! importFrom('sp', coordinates, CRS, GridTopology, points2grid, SpatialPoints, SpatialGridDataFrame, SpatialPointsDataFrame ) importFrom('RandomFieldsUtils', Print, RFoptions) #import(sp) #import(tcltk2, tcltk, tkrplot) export( ### internal fcts used for maintainance rfGenerateModels, rfGenerateConstants, rfGenerateTest, rfGenerateMaths, checkExamples, StartExample, FinalizeExample, maintainers.machine, ### some functions used in the examples ScreenDevice, ### obsolete CondSimu, Covariance, CovarianceFct, CovMatrix, DeleteAllRegisters, DeleteRegister, DoSimulateRF, EmpiricalVariogram, fitvario, fractal.dim, GaussRF, hurst, InitSimulateRF, InitGaussRF, InitMaxStableRF, Kriging, MaxStableRF, RFparameters, Variogram, plotWithCircles, ### maths max, min, ### others: ## never delete PrintModelList as it is used in Roger's book! PrintModelList, conventional2RFspDataFrame, sp2RF ) ## useDynLib(RFutils) useDynLib(RandomFields, .registration = TRUE, .fixes = "C_") # Classes exportClasses() exportMethods("[", "[<-", "+", "*", "/", "-", "^", c, show, plot, persp, anova, summary, points, lines, image, asin, atan, atan2, cos, sin, tan, acosh, asinh, atanh, cosh, sinh, tanh, exp, log, expm1, log1p, # logb, log2, sqrt, abs, floor, round, trunc, ## diag, lgamma) #, logLik, AIC, BIC) export(exp2, hypot, cbrt, erf, erfc) exportMethods(RFspDataFrame2conventional, RFspDataFrame2dataArray, # GridTopology2gridVectors, coerce, # coordinates, # isGridded, dimensions) ## S3 Methods S3method(as.data.frame, RFspatialGridDataFrame) S3method(as.data.frame, RFgridDataFrame) S3method(as.data.frame, RFspatialPointsDataFrame) S3method(as.data.frame, RFpointsDataFrame) S3method(as.matrix, RFspatialGridDataFrame) S3method(as.matrix, RFgridDataFrame) S3method(as.matrix, RFspatialPointsDataFrame) S3method(as.matrix, RFpointsDataFrame) S3method(as.array, RFspatialGridDataFrame) S3method(as.array, RFgridDataFrame) S3method(as.array, RFspatialPointsDataFrame) S3method(as.array, RFpointsDataFrame) S3method(as.vector, RFspatialGridDataFrame) S3method(as.vector, RFgridDataFrame) S3method(as.vector, RFspatialPointsDataFrame) S3method(as.vector, RFpointsDataFrame) S3method(summary, RFspatialGridDataFrame) S3method(summary, RFcrossvalidate) S3method(print, RFcrossvalidate) S3method(print, summary.RFcrossvalidate) S3method(contour, RFempVariog) S3method(print, RFempVariog) S3method(print, RF_empVariog) S3method(summary, RFempVariog) S3method(summary, RF_empVariog) S3method(print, summary.RFempVariog) S3method(AIC, RFfit) S3method(AIC, RF_fit) #S3method(AICc, RFmodelfit) S3method(anova, RFfit) S3method(anova, RF_fit) S3method(BIC, RFfit) S3method(BIC, RF_fit) S3method(logLik, RFfit) S3method(logLik, RF_fit) S3method(contour, RFfit) S3method(print, RFfit) S3method(print, RF_fit) S3method(residuals, RFfit) S3method(residuals, RF_fit) S3method(summary, RFfit) S3method(summary, RF_fit) S3method(print, AICRFfit) S3method(as.matrix, RFgridDataFrame) S3method(cbind, RFgridDataFrame) S3method(hist, RFgridDataFrame) S3method(range, RFgridDataFrame) S3method(print, RFgridDataFrame) S3method(summary, RFgridDataFrame) S3method(cbind, RFpointsDataFrame) S3method(hist, RFpointsDataFrame) S3method(range, RFpointsDataFrame) S3method(print, RFpointsDataFrame) S3method(summary, RFpointsDataFrame) S3method(print, summary.RFpointsDataFrame) S3method(cbind, RFspatialGridDataFrame) S3method(hist, RFspatialGridDataFrame) S3method(range, RFspatialGridDataFrame) S3method(print, RFspatialGridDataFrame) S3method(contour, RFspatialGridDataFrame) S3method(cbind, RFspatialPointsDataFrame) S3method(hist, RFspatialPointsDataFrame) S3method(range, RFspatialPointsDataFrame) S3method(print, RFspatialPointsDataFrame) S3method(summary, RFspatialPointsDataFrame) S3method(print, RFgetModelInfo) S3method(as.matrix, GridTopology) S3method(print, RFratiotest) S3method(lines, RMmodel) S3method(points,RMmodel) S3method(print, RMmodel) S3method(print, RM_model) S3method(str, RMmodel) S3method(summary, RMmodel) S3method(summary, RM_model) S3method(print, summary.RMmodel) S3method(print, RMmodelgenerator) #S3method(print, RandomFieldsReturn) #S3method(summary, RandomFieldsReturn) #S3method(print, summary.RandomFieldsReturn) S3method(anova, RMmodelFit) S3method(anova, RM_modelFit) S3method(print, RMmodelFit) S3method(print, RM_modelFit) S3method(summary, RMmodelFit) S3method(summary, RM_modelFit) S3method(print, summary.RMmodelFit) RandomFields/data/0000755000176200001440000000000013616050770013537 5ustar liggesusersRandomFields/data/weather.rda0000644000176200001440000000513513437301604015666 0ustar liggesusers]Xyx,&r"ZӺǵ7cfd *.O.I邖kt^vc % ;s/el0 ~chh,tWb$Wr9mPfN LeQqXk qCМU3 ?81]/ 'B?>P5'd @8a!w'π+\T qKCJɚCP[B}:`?Ec@)!OYz/Hx3祌D;9oNn@9:!ޝ!mw89xFxaBcQdx̀ѩ }T.b] &tN/P?  LM伷d_3o6{sǗ?qB׻|G=2;bNJb\~/.GFXw \|iSġ IXAM`<}#~[aGϣ/Е:agq3YZ<Lt>Bis΄?7cr~wؙ {~$G(8F~c<˨mT(T߸2`q3 {BɛvNsZǟ#}]Cut&FqzoFs,#ޟ( 1o?/b_$`e~s{ [_4go0F{E~.E?A%ӾnCg\`/7xlc%JHZ ^yq_#Q<z}mIsQVKy>WCܡl0@12 /@cߏ盱 $_; ek?C |7xA3: C&Ëм˲Hp:1wG땲vc,k+Xv"*8Fױޟy['/k!+ ͧkՌ6xD mk^opi<":9'sLkB7.vM =ӱr#_uv/><+W6%d^oo>%iPui.;jOˉ6Ii5c8G;t$<~3oD[+}bm^PB_p^sb/O$?jY?PBmvBW]kB{!XIB}&se_ׅ\]NKJ>hJyڐo)O )9yþK0o IWlKg+W+dCGLZ=?Cy|V{+:ynOwҾ#_GK=g!^-\noj΃MjmY~!ij9}L)1|'b>83T j{ymyXN؈OvtR.upt;WйUO,¹b9ݗo98ֻ<&웦]RihOꊝ3~'V EPc\L^t/ͫP%3|vWb̠|sVXrw]*t7n죺v^\OFs2egѺj+/쿜orIu/6kw7υ}~ j~ 5OZǿ!sy!ȹlulkƁ}sN柆>U0_4d6Ouu<9Cλ)x.»x) 뮸 ~8d?ko|9#Pb-T y9BCr{3ᓡ嫟zwji4jGqV ^ӟo^?.nG͗9^M5ovIY?2]k5?k8\2]WsyX秾<ԇiˈ%"Knk^_BE׷n/C_ -S{(aC~{e#_;&O'CG(7GytoԷj?qQ{4ڿ%d1j7>7~g^vݷu#3[|Qm}yv.5Zl(oh=r=}S@gi}^oXrm]q֝U_3zM<^f=˧~tnWdO,Xcdj=~=ݣ*OfhcߔR7v65̝טmtKщvՕc3:2SnɉW޷aNU%j$z*,UThRK,U9Bs#4Gh9Bs#2Gd9"sD#6Gl9bs#6Gl9s$H̑#1Gb9RsH͑#5Gj9Rs̑#3Gf92sd̑j9樚j9樚j9j標f9j標f9j[Y%+.d䒱K&.dUtUlg8[*VqU-tBg -tBg -t"g-r"g-r"g-vbg-vbg-vgK-qgK-qgK-uRgK-uRgK-u2g˜-s2g˜-s24_y<{!)ߘ՘j_+ؽw]{^o<9lǔz/Awə7b^Bz}~UZ}|- PӺO.Sߟ:Zf~5QGFuWN~{Sw'^yܛ=S듽P+{[i:zoҋ_gQt>qGm$RandomFields/data/soil.txt.gz0000644000176200001440000001664413437301604015674 0ustar liggesusers]ˮ$IRיO1IݗXlx,A㜢zN]~?_o?_??PouR^5>ܿ^3Fc _?-VJ*Wz~Fɣ>us~#ӏ񙹵̗׫O˫}R-kU^J@YUn|"5^)}U&BOk22sWjS[bIWj}˫<+u>J/ڬcZg= OSʕj^W͟c,Z[ɭ>n $45Gysj`$7xOmZ_*=kl >FG\6QXHjMm;}ca_~e(b r({9K?Dc8ZDH#ϖ4 ^]1gQez15FWuގtiGfz͉2{iW:3sB/*3q8ckCS/.fʜpͥ p-w¯Gb9%UJ5lS ̘\G#5~Y8dփ94#W'.iǫߏ+0̘&N!iR\%|Hz|}{LTYk[%>x@Ank8ɰki<#V̫#A$q!∯υS1yR n\ CA<TnQ7BEMx9b`{."2E ׃xݑY'Jqe87D_(?͘#y AvfLҎD+'7& 2iN|{,Pb d v@4Q?Az.!\+щ$e!~֘+g~aT h&ñ shHK(ЀjZ B>*Ok6 `[>ZL|-@}SI)cRMj$##ٸX ˮv@2zbaqay)n/&x@qNBb :B Y9* ']*&ޗv)REM t8/l_WKk/s[&A喘vWH{,pȔz|0cW[?A2S*-WI|3)-<|CCu1,b%%#A:Jo$cbI0O| [{|-(dp;p (}0nԞ[nZћ%" t <ũyAz' t(ǧq"sllJ初ϴ9%J^[ kX3O? ߄QI=<{;$B:i}yG؉Q|jm4h K+ 5EF@[8uh*[yd\MfYmK+6h@[_FP(5 Sp*T~2!/b b k"S(ZMIʣhҾcV8#0BtBɖ&7<syܒCqDaˏ@ <oƉTfPyR, uEr,q?i*^>Yd΁S6Eɖ7.sugSȝO%iɬT!>ab=E 4<ȿx#0 ѫZMpF  2UQI a~#)#pә'CsWR.m@Pfpo I$R`x^& ûB{oD [ȸ-M6ö-FC"mf+R5D@>%$b (bldvb){I ;|.(Q஺1;43葋kP &q DàaA-,sUXz 5$-6k8ڴvo i  `ɷ蘪@)ouB =[[Ԩ4P*>x ErU5(qϤ[gPCJWM( vA |Ѧiq^cGOLs&>/x4p5wx ?jAV@cnkG;vNc($5^bH#H-X]G6!Y?)JaZ(f,>7ފGR$ѠEJt${˞>zёkO?]_K}d7E[b{`Hn_CȮ9/B"XٍxHG"~-fwsެО>mA)!)IC!1_Vpf4U)v5S^ ' SIfoD9uTed>x[IYAJeaW}ӻv*pA4VJ&!ED󮻴VRx*F5MFL\rjؚ'OscM^9F/ 2իx+R$hd4q so|s^N~n8[cL rMtJ[s`y#(< xkB hxGpjDbLĜp/JݤBj`owٱ ,x $[ C G*M(]$NۺH[2(s&ޱHڭ W]$v`[\gD3񠵇p8.fN`XI^3ٵh:-9='ĕ_\7:+{ RO9!Q}b-P~2_8F='JNj)gO }ψʪLum0@dxo3mǰ%F݂% lO޷͠ˁ Uɰ/jK&iԣW4 ;? mX$gX1+ׇޢ~{nݥ"sTT8԰2tX >7 0R|;Ge e xQ6'N'-:ra)6Ƒb.Yu%@t6^zsPCQ~!}lw^vzlȥWo|ЭrdĸP)6@q RIpIP0H: p1ȐCPRΑYl1UӈЌJ^ܻ㞾gJ=MUs,ڢ?ù!D ی7. o:nrz7WFA:z=k& q+3;7LK|_!-NYH^v  &x[P %s~ր dKg{9m9k Q3nԣe uc\6!]*.2[|%UhV4r?Sm9A>]08u,h&*X?عL5u6f;Bډ5H&`%"90:)*ONY^7{/D+n:c`(1 \I 9Qwv^m<͉|)񱁕G؃pY "c؄+If+LmR. 0!ĵa)NFPY.\8"ŒT¥mϸWw 1Y9|0}11 wbvrc1!j{D.!F@+hdB[9$ Uvp= .FBt Ï !`@E"?T1(%bh3P6æ!2q/+Xz#"9]6v۴n6D ')7XH.s\IkN_dU#긱͆Z96 ϗ&vËqqV#l)CRǚN*):82l%M!:RsЊcKq@r -D !lƨ,8 ~@Br X>ٲ`ێ3jZ\*ҬIj+8$/VX&Ħ)8MHb <"9ɊXZӶBcYx-r\r⍃a6SyD%r_mʳ( Z4G u qN1 5n,e0k\;v_WMy';IYVt!-)Υ]䬔%͠lBW{v¢YFѴAMw|fNf |;wȂ@[GpNu&{{.WBָr0vc@ ZCDŽ|C'#&blQ`NM?C$/Gw-9^{"r-=FLZTMDj}L[h{p|`bk4bEfr/uCnR=ˡ 9W4In"/wh('t0޻n`r#欞3A'4U3v)T|}z{ԃ$cPrR-Jqhφ|9\LBdg0_i$/1x~ 3I)bq: g8sBB3a (Ob8TbR)xٚndϺSs(KW,Ym*IQ].\vi9j= ynoaY(-+^5qANԈlj`pӞ|oiQ8suD$M;qƿXbVTf1߲-bl빛(׸UF J4L|laʴV\L\o$#0A_QoB|F VWCݩ<`TR%Z^QZ=\mTJŔ\,ڳ)[o"YF!.0X8tZs;-go {uL_1jv#Jqc$Cj8=#Wv#-,8aK#nqCa[ذb>K8-/J{ q3Qgz81X~g[Gƿ\~F9 ;gɛ6-oE0`$W[A!}-_ wt+JvRC/rX¤Τ]1.j>mT{<]ߓx(-Qxv?;͗^qTN!z5ʾ{GQCʎ+5Ff܍ZWn0AՃ&۰R:+: 6V dKx!I|X́ &gUX?f$]jKO>PQx(ofLq}snL΂n3vի]C9亅^ܵGו Ԋ=h o}oIQ ?c;{GsSawEchXm ?f$%Qd(nfZ!l9}?qhyEC^ǭ{U{ rړ!E "w7]b#bX,1+.FB7%Kѻ9ڋB.̥F 9:xeg^-Ow:2X?l\_MqQっ*#pj7IfGǦ]}IȫWo(׃tԡ&ȴʿׂ1T&Yn{R׶3]{99y.8#E=0*rTwDz/!1@E9s:,}T9-&ۭ -)} D n8\z/nѼ+D=l/\O=lӷ{Ēa!.FePk<Ձ ,!-2 $=iwƪq7|/ ^TY뺤{,TXR7vM?jq?x+FuI.w/& >kD\)B/=xS4W\y7Γ2c%yM%u~'#ĨS!2?|^I칎8[,LخhF?K77\EiS=]Lyœ~XeX/F徔fY$e} IkB }-? E_sm͠ %v,lu}mlO\F.6e̠Et "E]jMɾwv5dˊ)Yx?兽\Χx`D -˄c;*S%ևd!id`Yzv_JX5U/}/\z;[:3oUZE~gIa.*,N,|b]rUdG4Ү%|LwcBOv3uיRQ}R=~m2J֍ @Ctw?>|/xa&&B־KVˆaYтp=/8amIX$/_ΌMԙ3 q.;?ƫ/.;UW4O+ʆxS*d}vި:~i3kv"zŕGҊc/{"~!&=RandomFields/man/0000755000176200001440000000000013616114744013403 5ustar liggesusersRandomFields/man/RMintrinsic.Rd0000644000176200001440000000542613437301604016134 0ustar liggesusers\name{RMintrinsic} \alias{RMintrinsic} \title{Intrinsic Embedding Covariance Model} \description{ \command{\link{RMintrinsic}} is a univariate stationary isotropic covariance model which depends on a univariate stationary isotropic covariance model. The corresponding covariance function C of the model only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r)=a_0 + a_2 r^2 + \phi(r), 0\le r \le diameter} \deqn{C(r)=b_0 (rawR D - r)^3/(r), diameter \le r \le rawR * diameter} \deqn{C(r) = 0, rawR * diameter \le r} } \usage{ RMintrinsic(phi, diameter, rawR, var, scale, Aniso, proj) } \arguments{ \item{phi}{an \command{\link{RMmodel}}; has to be stationary and isotropic} \item{diameter}{a numerical value; positive; should be the diameter of the domain on which simulation is done} \item{rawR}{a numerical value; greater or equal to 1} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The parameters \eqn{a_0}, \eqn{a_2} and \eqn{b_0} are chosen internally such that \eqn{C} becomes a smooth function. See formulas (3.8)-(3.10) in Gneiting et alii (2006). This model corresponds to the method Intrinsic Embedding. See also \code{\link{RPintrinsic}}. NOTE: The algorithm that checks the given parameters knows only about some few necessary conditions. Hence it is not ensured that the Stein-model is a valid covariance function for any choice of \eqn{\phi} and the parameters. For certain models \eqn{\phi}{phi}, i.e. \code{stable}, \code{whittle}, \code{gencauchy}, and the variogram model \code{fractalB} some sufficient conditions are known. } \value{ \command{\link{RMintrinsic}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large {G}aussian Lattice Systems in {$R^2$}: Exploring the Limits. \emph{J. Comput. Graph. Stat.} \bold{15}, 483--501. \item Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599 } } \me \seealso{ \command{\link{RPintrinsic}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x.max <- 10 model <- RMintrinsic(RMfbm(alpha=1), diameter=x.max) x <- seq(0, x.max, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMconstant.Rd0000644000176200001440000000204213437301604015752 0ustar liggesusers\name{RMconstant} \alias{RMconstant} \alias{RMconstant} \title{Covariance Matrix Constant in Space} \description{ \command{\link{RMconstant}} defines a spatially constant covariance function. } \usage{ RMconstant(M, var) } \arguments{ \item{M}{a numerical matrix defining the user-defined covariance for a random field; the matrix should be positive definite, symmetric and its dimension should be equal to the length of observation or simulation vector.} \item{var}{ variance } } \value{ \command{\link{RMconstant}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMfixcov}}, \command{\link{RMmodel}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMconstant(diag(2),var=3) plot(model) x <- seq(0,10,length=100) z <- RFsimulate(model=model,x=x) \dontshow{FinalizeExample()}}RandomFields/man/RMdewijsian.Rd0000644000176200001440000000443413437301604016105 0ustar liggesusers\name{RMdewijsian} \alias{RMdewijsian} \title{Modified De Wijsian Variogram Model} \description{ The modified \command{RMdewijsian} model is an intrinsically stationary isotropic variogram model. The corresponding centered semi-variogram only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{\gamma(r) = \log(r^{\alpha}+1)}{\gamma(r)=log(r^{\alpha}+1)} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2}. } \usage{ RMdewijsian(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; in the interval (0,2].} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above variogram remains unmodified.} } \details{ Originally, the logarithmic model \eqn{\gamma(r) = \log(r)} was named after de Wijs and reflects a principle of similarity (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 90). But note that \eqn{\gamma(r) = \log(r)} is not a valid variogram (\eqn{\gamma(0)} does not vanish) and can only be understood as a characteristic of a generalized random field. The modified \code{RMdewijsian} model \eqn{\gamma(r) = \log(r^{\alpha}+1)} is a valid variogram model (cf. Wackernagel, H. (2003), p. 336). } \value{ \command{\link{RMdewijsian}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{Note that the (non-modified) de Wijsian model equals \eqn{\gamma(r) = \log(r)}.} \references{ \itemize{ % \item Chiles, J.-P. and Delfiner, P. (1999) % \emph{Geostatistics. Modeling Spatial Uncertainty.} % New York: Wiley. \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3nd edition. % \item Martin's Toledo-Chapter: Construction of covariance functions % and unconditional simulation of random fields, Example 7 } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdewijsian(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMnatsc.Rd0000644000176200001440000000246013437301604015235 0ustar liggesusers\name{RMnatsc} \alias{RMnatsc} \title{Natural scale} \description{ \command{\link{RMnatsc}} is a stationary isotropic covariance model that depends on a stationary isotropic covariance model \eqn{\phi}{phi}. The covariance is given by \deqn{ C(h) = \phi(h / s) }{ C(h) = phi(h / s),} where the argument \code{s} is chosen by \command{\link{RMnatsc}} such that the practical range or the mathematical range, if finite, is 1. } \usage{ RMnatsc(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{a stationary isotropic covariance \command{\link{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ For internal use only. } \value{ \command{\link{RMnatsc}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } %\references{} \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnatsc(RMexp()) x <- seq(0, 10, 0.02) plot(RMexp(), model=model) RFcov(model, 1) \dontshow{FinalizeExample()} }RandomFields/man/RFoptions.Rd0000644000176200001440000022412113437301604015611 0ustar liggesusers\name{RFoptions} \alias{RFoptions} \alias{RFOPTIONS} \title{Setting control arguments} \description{ \command{\link{RFoptions}} sets and returns control arguments for the analysis and the simulation of random fields. It expands the functionality of \link[RandomFieldsUtils]{RFoptions}. } \section{Usage}{ RFoptions(...) } \section{Arguments}{ \describe{ \item{...}{arguments in \code{tag = value} form, or a list of tagged values.} } %\item{no.readonly}{If \command{\link{RFoptions}} is called without % argument then all arguments are returned in a list. If % \code{no.readonly=TRUE} then only rewritable arguments are returned. % } } \section{Details}{ The subsections below comment on\cr \bold{0. \code{basic}: \RFU}\cr \bold{1. \code{general}: General options}\cr \bold{2. \code{br}: Options for Brown-Resnick Fields}\cr \bold{3. \code{circulant}: Options for circulant embedding methods \command{\link{RPcirculant}}}\cr \bold{4. \code{coords}: Options for coordinates and units, see \link{coordinate systems}}\cr \bold{5. \code{direct}: Options for simulating by simple matrix decomposition}\cr \bold{6. \code{distr}: Options for distributions, in particular \command{\link{RRrectangular}}}\cr \bold{7. \code{empvario}: Options for calculating the empirical variogram}\cr \bold{8. \code{fit}: Options for \command{\link{RFfit}}, \command{\link{RFratiotest}}, and \command{\link{RFcrossvalidate}}}\cr \bold{9. \code{gauss}: Options for simulating Gaussian random fields}\cr \bold{10. \code{graphics}: Options for graphical output}\cr \bold{11. \code{gui}: Options for \command{\link{RFgui}}}\cr \bold{12. \code{hyper}: Options for simulating hyperplane tessellations}\cr \bold{13. \code{krige}: Options for Kriging}\cr \bold{14. \code{maxstable}: Options for simulating max-stable random fields}\cr \bold{15. \code{mpp}: Options for the random coins (shot noise) methods}\cr \bold{16. \code{nugget}: Options for the nugget effect}\cr \bold{17. \code{registers}: Register numbers}\cr \bold{18. \code{sequ}: Options for the sequential method}\cr \bold{19. \code{solve}: Options for solving linear systems}\cr \bold{20. \code{special}: Options for some special methods}\cr \bold{21. \code{spectral}: Options for the spectral (turning bands) method}\cr \bold{22. \code{tbm}: Options for the turning bands method}\cr \bold{23. \code{internal}: Internal}\cr\cr\cr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \bold{16. Options for RFloglikelihood}\cr % % "auto", "full", "composite", "selection" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{1. General options} \describe{ % only works for RFsimulate, not for RFsimulate \item{\code{allowdistanceZero}}{boolean. Only used in \command{\link{RFinterpolate}} and in \command{\link{RFfit}}. If true, then multiple observations or identical locations are allowed within a single data set. In this case, the coordinates are slightly scattered, so that the points have some tiny distances. Default: \code{FALSE}. } \item{\code{cPrintlevel}}{ \code{cPrintlevel} is automatically set to \code{printlevel} when \code{printlevel} is changed. Standard users will never use a value higher than 3. 0 : no messages\cr 1 : messages and warnings when the user's input looks odd\cr 2 : messages (and internal errors) documenting the choice of the simulation method\cr 3 : further user relevant informations\cr 4 : information on recursive function calls\cr 5 : function flow information of central functions \cr 6 : errors that are internally treated\cr 7 : details on building up the covariance structure\cr 8 : details on taking the square root of the covariance matrix\cr 9 : details on intermediate calculations\cr 10 : further details on intermediate calculations\cr Note that \code{printlevel} works on the R level whereas \code{cPrintlevel} works on the C level. Default: 1 \cr % [also do].\cr } \item{\code{detailed_output}}{logical. if \code{TRUE} some function, e.g. \code{\link{RFcrossvalidate}} will return additional information. } \item{\code{every}}{integer. if greater than zero, then every \code{every}th iteration is printed if simulated by TBM or random coin method. The value zero means that nothing is printed. Default: \code{0} % [do]. } \item{\code{exactness}}{logical or NA. Currently only used when simulating Gaussian random fields. \itemize{ \item \code{TRUE}: \command{\link{RPcoins}}, \command{\link{RPhyperplane}}, \command{\link{RPsequential}}, \command{\link{RPspectral}} and \command{\link{RPtbm}} and \emph{approximative} circulant embedding are excluded. If the circulant embedding method is considered as badly behaved, then the matrix decomposition methods are preferred. \item \code{FALSE}: all the methods are allowed. If the circulant embedding method is considered as badly behaved or the number of points to be simulated is large, the turning bands methods are rather preferred. \item \code{NA}: Similar to \code{FALSE}, but some inexact algorithms get less preference. } Default: \code{NA} . } \item{\code{expected_number_simu}}{positive integer which is usally set internally as the value of the argument \code{n} in \command{\link{RFsimulate}}. The argument \code{expected_number_simu} should be set only by an advanced users and only if \command{\link{RFsimulate}} will be called with argument \code{n} alone. } \item{\code{gridtolerance}}{ used in \command{\link{RFsimulate}} to see if the coordinates build a grid for x, y, z, T-values. This argument is also used in case of conditional simulation where the data locations might ly on a grid. Default: \code{1e-6} } \item{asList}{logical. Lists of arguments are treated slightly different from non-lists. If \code{asList=FALSE} they are treated the same way as non-lists. This options being set to \code{FALSE} after calling \command{RFoptions} it should be set as first element of a list. Default: \code{TRUE} } \item{\code{modus_operandi}}{character. One of the values \code{"careless"}, \code{"sloppy"}, \code{"easygoing"}, \code{"normal"}, \code{"precise"}, \code{"pedantic"}, \code{"neurotic"} . \bold{This argument is in an experimental stage and its definition and effects will change very likely in near future.}%to do This argument sets a lot of argument at once related to estimation and simulation. \code{"careless"} prefers rather fast algorithms, but the results might be very rough approximations. By way of contrast, \code{"neurotic"} will try very hard to return exact result at the cost of hugh computing times. Default: \code{"normal"} } \item{\code{na_rm_lines}}{ logical. If \code{TRUE} then a line of the data that contains a \code{NA} value is deleted. Otherwise it is tried to deal with the \code{NA} value at higher costs of computing time. (Only used for kriging -- estimation can fully deal with \code{NA}s.) Default: \code{FALSE}. } \item{\code{output}}{character. one of the values \code{"sp"} (if and only if \code{spConform=TRUE}), \code{"RandomFields"} (if and only if \code{spConform=FALSE}), \code{"geoR"}. The output mode \code{geoR} currently adds some attributes such as the call of the function. NOTE: \code{output} is in an experimental stage, whose effects might change in future. Currently, \code{output} changes the values of \code{reportcoord}, \code{returncall} and \code{spConform}. } \item{\code{pch}}{character. \command{\link{RFfit}}: shown before evaluating any method; if \code{pch!=""} then one or two additional steps in the MLE methods are marked by \dQuote{+} and \dQuote{#}. Simulation: The character is printed after each performed simulation if more than one simulation is performed at once. If \code{pch='!'} then an absolute counter is shown instead of the character. If \code{pch='\%'} then a counter of percentages is shown instead of the character. Note that also \sQuote{\eqn{\mbox{\textasciicircum}}{^}H}s are printed in the last two cases, which may have undesirable interactions with some few other R functions, e.g. \command{\link[utils]{Sweave}}. Default: \code{'*'}. % [do]. } \item{\code{practicalrange}}{logical or integer. If not \code{FALSE} the range of primitive covariance functions is adjusted so that cov(1) is zero for models with finite range. (Operators are too complex to be adjusted; for anisotropic covariance the practical range is not well defined.) The value of cov(1) is about 0.05 (for \code{scale=1}) for models without range. See \command{\link{RMmodel}} or type \cr \code{\link{RFgetModelNames}(type="positive definite", domain="single variable", isotropy="isotropic", operator=FALSE, vdim=1)} \cr for the list of primitive models. \itemize{ \item \code{FALSE} : the practical range ajustment is not used. \item \code{TRUE} : \code{practicalrange} is applicable only if the value is known exactly, or, at least, can be approximated by a closed formula. \item \code{2} : if the practical range is not known exactly it is approximated numerically. } Default: \code{FALSE} . } \item{\code{printlevel}}{If \code{printlevel}\eqn{\le0}{<=0} there is not any output on the screen. The higher the number the more tracing information is given. Standard users will never use a value higher than 3. 0 : no messages\cr 1 : important (error) messages and warnings\cr 2 : less important messages\cr 3 : details, but still for the user\cr 4 : recursive call tracing (only used within \command{\link{RFfit}})\cr 5 : function flow information of large functions\cr 6 : errors that are internally treated\cr 7 : details on intermediate calculations\cr 8 : further details on intermediate calculations\cr Default: 1 %[also do].\cr } \item{reportcoord}{character. Current values are \code{"always"}, \code{"important"}, \code{"warn"}, \code{"never"}, Both \code{"warn"} and \code{"important"} have any effect only if the coordinate system is changed internally. In this case \code{"warn"} yields a displayed warning message whereas \code{"important"} adds an attribute to the result as in the case \code{"always"}. If \code{"always"} or \code{"important"} the reports are added as attribute to the results. Note that in this case the class of the result may change (e.g. from \code{"numeric"} to \code{"atomic"}). Default: \code{"warn"} } \item{returncall}{logical. If \code{TRUE} then the call is returned as an attribute Default: \code{TRUE} } \item{seed}{integer. If \code{NULL} or \code{NA} \command{\link{set.seed}} is \bold{not} called. Otherwise, \code{\link[base]{set.seed}(seed)} is set before simulations are performed, e.g. by \command{\link{RFsimulate}} or \command{\link{RFdistr}}. If the argument is set locally, i.e., within a function, it has the usual local effect. If it is set globally, i.e. by \command{RFoptions} the \code{seed} is fixed for \bold{all subsequent} calls. If the number of simulations \code{n} is greater than one and if \code{RFoptions(seed=seed)} is set, the \eqn{i}th simulation is started with the seed \sQuote{\code{seed}\eqn{+i-1}}. % The function \code{set.seed} should not be used in case \code{n} % is greater than 1. % %Vgle! %set.seed(5) %RFsimulate(RPschlather(RMmatern(nu=2), xi=1, mu=1, s=1), x, grid=F, n=5)@data %set.seed(5) %RFsimulate(RPschlather(RMmatern(nu=2.01), xi=1, mu=1, s=1), x,grid=F,n=5)@data %RFoptions(cPr=3, seed=5) %RFsimulate(RPschlather(RMmatern(nu=2), xi=1, mu=1, s=1), x, grid=F, n=5)@data %RFsimulate(RPschlather(RMmatern(nu=2.01), xi=1, mu=1, s=1), x, grid=F,n=5)@data Note also that \command{\link{RFratiotest}} has its own argument \code{seed} with a slightly different meaning. } \item{seed_incr, seed_sub_incr}{ (does not work yet) This argument is important iff \command{RFsimulate} is used within a function from package \pkg{parallel}. The value of \code{seed_incr} should be set only locally, i.e. not by \code{RFoptions()}. If \code{seed_incr != 0} (or the number of simulations \code{n} is greater than 1) and \code{!is.na(seed)} then the seed for each simulation is calculated as \code{seed} \eqn{+ (k-1) *} \code{seed_sub_incr} \eqn{+} \code{seed_incr} \eqn{* n} where \eqn{k} runs from 1 to \code{n}. Default: 0 } \item{\code{set}}{integer. Certain models (e.g. \command{\link{RMfixcov}} and \command{\link{RMcovariate}}) allow for lists as arguments. \code{set} selects a certain list element. If necessary the list is recycled. } \item{\code{spConform}}{logical. \code{spConform=TRUE} might be used by a standard user as this allows the comfortable use of \command{plot}, for instance, while \code{spConform=FALSE} is \bold{much} faster and and consumes \bold{much less memory}, hence might be used by programmers or advanced users. Details: if \code{spConform=TRUE} then \command{\link{RFsimulate}} and many other functions return an \code{sp}-object (which is an S4 object). Otherwise, matrices or lists are returned as defined in RandomFields 2.0, see the manuals for the specific functions. Frequently, the latter have now a class attribute to make the output nicer. Note: for large data sets (to be generated), \code{spConform=TRUE} should \bold{not} be used. See also \code{output}. Default: \code{TRUE} %[do]. } \item{\code{skipchecks}}{logical. If \code{TRUE}, several checks whether the given parameter values and the dimension are within the allowed range is skipped. Do not change the value of this variable except you really know what you do. Default: \code{FALSE} $ %[also do]. } \item{\code{storing}}{Logical. If \code{FALSE} then the intermediate results are destroyed after the simulation of the random field(s) or if an error had occured. If \code{storing=TRUE}, then additional simulations can be performed by calling \command{\link{RFsimulate}} with at most the argument \code{n}. This call can then be much faster, but the a rather large amount of memory could be kept. When \code{storing} turned from \code{TRUE} to \code{FALSE} by global call then all registers are deleted. Advanced: With \code{\link{RFoptions}(storing=list(FALSE, register, model_register))} single registers can be deleted. Default: \code{FALSE} %[do]. } \item{\code{Ttriple}}{Logical or \code{NA}. If \code{TRUE}, then triple for the time argument \code{T} is expected, containing start, step (by), length. If \code{FALSE} a sequence on a grid is expected. If \code{NA} then the decision is automatic, but will lead to an error if ambiguous. } \item{\code{vdim_close_together}}{logical. Used especially in functions that create covariance matrices. If the model is multivariate, then two ways of ordering the matrix exist. To consider first all variables at a certain location (\code{vdim_close_together=TRUE}) or to consider first all locations keeping the variable fixed (\code{vdim_close_together=FALSE}). Note that several simulation methods rely on the value \code{FALSE}, so that these methods will not work anymore if \code{vdim_close_together=FALSE}. Default: \code{FALSE}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{2. Options for Brown-Resnick Fields} \describe{ \item{\code{deltaAM}}{ integer; only used for simulation of BR processes via \code{RPbrmixed} with \code{optim_mixed=2}. In this case, \code{deltaAM} is the number of additionally simulated Gaussian processes used for an update of \code{\link[=RPbrmixed]{areamat}} in the optimization pricedure. Default: \code{300} } \item{\code{maxtrendmem}}{ integer; the maximal number of real valued variables used for intermediate storage: \itemize{ \item RPbrshifted: trends for shifted locations that may be stored at the same time when simulating BR processes. \item RPbrnormed: Let \eqn{n} be the number of locations. Then a \eqn{n\times n} (covariance) matrix has to be evaluated at random columns. } if \code{maxtrendmem} is large (and \eqn{n} small, \eqn{n\le 10^4}), multiple evaluations can be avoided. Default: \code{1e7} . } \item{\code{meshsize}}{ positive; width of the grid on which the shape functions in the M3 representation of BR processes are simulated; only used for simulation of BR processes via \code{RPbrmixed}. Default: \code{0.1} . } \item{\code{optim_mixed}}{\code{0, 1, 2}; only used for simulation of BR processes via \code{RPbrmixed}.\cr If \code{optim_mixed=0}, the arguments \code{\link[=RPbrmixed]{lambda}} and \code{\link[=RPbrmixed]{areamat}} of \command{\link{RPbrmixed}} are used for the simulation.\cr If \code{optim_mixed=1}, \code{\link[=RPbrmixed]{lambda}} is estimated for \code{\link[=RPbrmixed]{areamat=1}}.\cr If \code{optim_mixed=2}, \code{\link[=RPbrmixed]{areamat}} is optimized and \code{\link[=RPbrmixed]{lambda}} is estimated. Default: \code{1} . } \item{\code{optim_mixed_tol}}{ value in \eqn{[0,1]}; only used for simulation of BR processes via \code{RPbrmixed} with \code{optim_mixed=2}. In this case, \code{\link[=RPbrmixed]{areamat}} is optimized under the constraint that the probability of drawing the shape function incorrectly is bounded by \code{optim_mixed_tol} (cf. Oesting et al., 2012). Default: \code{0.01} . } \item{\code{variobound}}{ positive; the shape functions in the mixed moving maxima representation are cut off where the variogram belonging to \code{phi} exceeds \code{variobound}. Default: \code{8.0} . } \item{\code{vertnumber}}{ positive integer; for an efficient simulation of the shape functions in the M3 representation of BR processes, the component \eqn{E} from of the domain \eqn{[x_0, \infty] \times E}{[x_0, Inf] x E} of the underlying Poisson point process is sub-dividedinto cubes (cf. Oesting et al., 2012); \code{vertical} is the number of vertical breaks of \eqn{E}; only used for simulation of BR processes via \code{RPbrmixed} with \code{optim_mixed=2}. Default: \code{7} . } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{3. \code{circulant}: Options for circulant embedding methods, cf. \command{\link{RPcirculant}}}\cr These options influence the standard circulant embedding method, cutoff circulant embedding intrinsic circulant embedding. It can also influence \command{\link{RPtbm}} if the line is simulated with any circulant embedding method. \cr \describe{ \item{\code{approx_maxgrid}}{See \command{\link{RPcirculant}}} \item{\code{approx_step}}{See \command{\link{RPcirculant}}} \item{\code{dependent}}{See \command{\link{RPcirculant}}} \item{\code{force}}{See \command{\link{RPcirculant}}} \item{\code{maxGB}}{See \command{\link{RPcirculant}}} \item{\code{maxmem}}{See \command{\link{RPcirculant}}} \item{\code{mmin}}{See \command{\link{RPcirculant}}} \item{\code{strategy}}{See \command{\link{RPcirculant}}} \item{\code{tolIm}}{See \command{\link{RPcirculant}}} \item{\code{tolRe}}{See \command{\link{RPcirculant}}} \item{\code{trials}}{See \command{\link{RPcirculant}}} \item{\code{useprimes}}{See \command{\link{RPcirculant}}} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{4. \code{coords}: Options for coordinates and units} \describe{ \item{\code{coord_system}}{character. See \link{coordinate systems} } \item{\code{coordunits}}{ See \link{coordinate systems} } \item{\code{coordnames}}{See \link{coordinate systems} } \item{\code{new_coord_system}}{See \link{coordinate systems} } \item{\code{new_coordunits}}{See \link{coordinate systems} } \item{\code{polar_coord} }{See \link{coordinate systems} } \item{\code{varnames}}{See \link{coordinate systems} } \item{\code{varunits}}{See \link{coordinate systems} } \item{\code{xyz_notation}}{See \link{coordinate systems} } \item{\code{zenit}}{See \link{coordinate systems} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{5. \code{direct}: Options for simulating by simple matrix decomposition} \describe{ \item{\code{max_variab}}{Maximal size of the covariance matrix. Default: 12000 } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{6. \code{distr}: Options for distributions, in particular \command{\link{RRrectangular}}} \describe{ \item{\code{innermin}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. The minimal length of the interval where the Taylor expansion shall be valid. Default: \code{1e-20} . } \item{\code{maxit}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. The number of iterative steps where the the constant of the Taylor development is increased, to find an upper bound for the given function. Default: \code{20} . } \item{\code{maxsteps}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. \code{maxsteps} is usually the number of steps in the middle part of the approximation. From this value and the length between the determined endpoints for the approximation at the origin and in the tail, the step length is calculated. If the step length is less than \code{minsteplen} the number of steps is reduced. Default: \code{1000} . } \item{\code{mcmc_n}}{ In case of the use of MCMC it leaves out \eqn{n-1} member of the Markov chain bevor the \eqn{n} member is returned. See also maxsteps. Default: \code{15} . } \item{\code{minsteplen}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. The minimal step length for the middle part of approximation, which is a step function, Default: \code{0} (i.e. not used as a criterion.) } \item{\code{outermax}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. The largest possible endpoint for the middle part that approximates the function by a step function. See also \code{innermax}. Default: 20. } \item{\code{parts}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. \code{parts} determines the number of tests that are performed to check whether a proposed power function is an upper bound for the given function, at the origin and the tail. Default: \code{8} . } \item{\code{repetitions}}{ Minimal number of realisations to determine a quantity of the distribution by MCMC. E.g. to determine the integral value \eqn{c} in the paper of Oesting, Schlather, Zhou. Default: 1000. } \item{\code{safety}}{ Default value to simulate from the \command{\link{RRrectangular}} distribution. First, at the origin, the first power function of the Taylor expansion is taken as potential upper function. The constant of the power function are increased by factor \eqn{1 + }\code{safety} and the exponent of the function similarly decreased. A number of test evaluations is performed to check whether this modified function is indeed a upper bound. If not, the considered interval at the origin is reduced iteratively, the constants of the power function further increased and the exponent decreased. If \code{maxit} iteration have been performed without success, the search for an upper bound fails. The search at the origin also fails if the interval around the origin has become less than \code{innermin}. Similar procedure is performed for the tail. Default: \code{0.08} . } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{7. \code{empvario}: Options for calculating the empirical variogram} \describe{ \item{\code{fft}}{ Logical. Determines whether FFT should be used for data on a grid Default: \code{TRUE}. } \item{\code{phi0}}{ numeric. In case of anisotropic fields directional cones are considered. The argument \code{phi0} determines the starting angle. Default: \code{0}. } \item{\code{pseudovariogram}}{ logical. Only in the multivariate case. Whether the pseudovariogram or the crossvariogram should be calculated. Default: \code{FALSE}. } \item{\code{theta0}}{ numeric. In case of anisotropic fields directional cones are considered. The argument \code{theta0} determines one of the boundaries, hence all boundaries for a given fixed number of cones. The argument \code{theta0} determines the starting value of the second anglue in polar coordinate representation in 3 dimensions. Default: \code{0}. } \item{\code{tol0}}{ numeric. Estimated values of the empirical variogram below \code{tol0} times the grid step in the third dimension are considered to be zero. Hence the respective values are set to zero. Default: \code{1e-13}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{8. \code{fit}: Options for \command{\link{RFfit}}, \command{\link{RFratiotest}}, and \command{\link{RFcrossvalidate}}} \describe{ \item{\code{algorithm}}{ See \link{RFfitOptimiser}. Default: \code{NULL} } \item{\code{approximate_functioncalls}}{ In case the parameter vector is too close to the given bounds, the ML target function is evaluated on a grid to get a new initial value for the ML estimation. The number of points of the grid is approximately \code{approximate_functioncalls}. Default: \code{50} } \item{\code{boxcox_lb}}{ lower bound for the Box-Cox transformation Default: \code{-10}. } \item{\code{boxcox_ub}}{ upper bound for the Box-Cox transformation Default: \code{10}. } \item{\code{bin_dist_factor}}{ numeric. The empirical variogram is calculated up the distance \code{bin_dist_factor} times (maximum distance among any pair of locations) Default: \code{0.5}. } \item{\code{bins}}{vector of explicit boundaries for the bins or the number of bins for the empirical variogram (used in the LSQ target function, which is described at the beginning of the Details). Note that for anisotropic models, the value of \code{bins} might be enlarged. Default: \code{20}. } \item{\code{critical}}{logical or signed integer. If \code{critical=FALSE} and if the result of any maximum likelihood method is on a borderline, then the optimisation is redone in a modified way (which takes about double extra time) If \code{critical=TRUE} and if the result of any maximum likelihood method is on a borderline, then a kind of profile likelihood optimization is done (which takes about 10 times extra time) If \code{critical>=2} then a kind of profile likelihood optimization is always done (which takes about \code{n_crit} times extra time) for an automatically chosen selection of the model parameters. If \code{critical>=3} then a kind of profile likelihood optimization is always done (which takes about \code{n_crit} times extra time) for all the parameters. If \code{critical<0} then none of the refined methods are performed. Default: \code{TRUE}. } \item{\code{cross_refit}}{logical. For each of the subset of the cross-validation method the parameters have to be fitted to the given model. If \code{cross_refit} is \code{TRUE}, this is done, but takes a huge amount of time. If \code{FALSE}, the model is fitted only once to the data and the value at each point is predicted with the same model given the values of the other points. Default: \code{FALSE}. } \item{estimate_variance}{ see \command{\link{RFlikelihood}}. } \item{factr, factr_recall}{ See the argument \code{control} in \link[stats]{optim}. \code{factr_recall} is used for intermediate calculations. } \item{likelihood}{character -- not programmed yet. types of likelihood are \code{"auto"}, \code{"full"}, \code{"composite"}, \code{"tesselation"}; Default: \code{"auto"} } \item{\code{lowerbound_scale_factor}}{ The lower bound for the scale is determined as (minimum distance between different pairs of points) /\cr \code{lowerbound_scale_factor}. Default: \code{3}. } \item{\code{lowerbound_scale_ls_factor}}{ For the LSQ target function a different lower bound for the scale is used. It is determined as (minimum distance between different pairs of points) / \cr \code{lowerbound_scale_ls_factor}. Default: \code{5}. } % \item{\code{lowerbound_sill}}{absolute lower bound for variance % and nugget. See \code{lowerbound_var_factor}. % % Default: \code{1E-10}. % } \item{\code{lowerbound_var_factor}}{ The lower bound for the nugget and the variance is determined as var(\code{data}) / \code{lowerbound_var_factor}. If a standard model definition is given and either the nugget or the variance is fixed, the parameter to be estimated must also be greater than \code{lowerbound_sill}. Default: \code{10000}. } \item{\code{maxmixedvar}}{OBSOLETE. upper bound for variance in a mixed model; so, the covariance model for mixed model part might be calibrated appropriately } \item{\code{max_neighbours}}{integer. Maximum number of locations (with depending values) that are allowed. Default: \code{5000}. } \item{\code{minbounddistance}}{ If any value of the parameter vector returned from the ML estimation is closer than \code{minbounddistance} to any of the bounds or if any value has a relative distance smaller than \code{minboundreldist}, then it is assumed that the MLE algorithm has dropped into a local minimum, and it will be continued with evaluating the ML target function on a grid, cf. the beginning paragraphs of the Details. Default: \code{0.001}. } \item{\code{minboundreldist}}{relative distance to the bounds below which a part of the algorithm is considered as having failed. See \code{minbounddistance}. Default: \code{0.02}. } \item{\code{min_diag}}{ Minimal value of any estimated diagonal matrix element. Default: \code{1e-7}. } \item{\code{n_crit}}{integer. The approximate profiles that are considered. Default: \code{10}. } \item{\code{nphi}}{scalar or vector of 2 components. If it is a vector then the first component gives the first angle of the xy plane and the second one gives the number of directions on the half circle. If scalar then the first angle is assumed to be zero. Note that a good estimation of the variogramm by LSQ with a anisotropic model a large value for \code{ntheta} might be needed (about 20). Default: \code{1}. } \item{\code{ntheta}}{scalar or vector of 2 components. If it is a vector then the first component gives the first angle in the third direction and the second one gives the number of directions on the half circle. If scalar then the first angle is assumed to be zero. Note that a good estimation of the variogramm by LSQ with a anisotropic model a large value for \code{ntheta} might be needed (about 20). Default: \code{1}. } \item{\code{ntime}}{scalar or vector of 2 components. if \code{ntimes} is a vector, then the first component are the maximum time distance (in units of the grid length \code{T[3]}) and the second component gives the step size (in units of the grid length \code{T[3]}). If scalar then the step size is assumed to 1 (in units of the grid length \code{T[3]}). Default: \code{20}. } \item{\code{only_users}}{boolean. If true then only \code{users_guess} is used as a starting point for the fitting algorithms Default: \code{FALSE}. } \item{\code{optimiser}}{ See \link{RFfitOptimiser}. Default: \code{"optim"}. } % \item{\code{optim_var_elimination}}{This argument takes the values % \code{'never'}, \code{'respect bound'}, \code{'try'}, % \code{'yes'}, and should only be % set by the advanced user. Background of this option is that % a global variance can optimized analytically. % % The meaning of the values is as follows. % \itemize{ % \item{\code{'never'}}{ % A global variance is never tried to be eliminated % } % \item{\code{'respect bound'}}{ % A global variance is eliminated if such a variance % is detected and the user did not indicate bounds % for the parameters. % } % \item{\code{'try'}}{ % A global variance is eliminated if such a variance % is detected. % } % \item{\code{'yes'}}{ % A global variance is tried to be eliminated altough % the algorithm did not find an indication. Here, the full % responsibility is left to the user. (This option might % make sense if \code{transform} is given.) % This option is only overwritten when it does not make sense, % e.g. no variance is estimated. % } % } % Default: \code{'respect bound'}. % } \item{pgtol, pgtol_recall}{ See the argument \code{control} in \link[stats]{optim}. \code{pgtol_recall} is used for intermediate calculations. } \item{\code{refine_onborder}}{logical. If \code{TRUE} and an estimated parameter of the model is close to the boundary, a second search for the optimum is started. Default: \code{TRUE} } \item{\code{minmixedvar}}{ lower bound for variance in a mixed model; so, the covariance model for mixed model part might be calibrated appropriately Default: 1/1000 } % \item{\code{solvesigma}}{Logical. -- experimental stage! % If a mixed effect part is present where the variance % has to be estimated, then this variance parameter is solved % iteratively within the profile likelihood function, if % \code{solvesigma=TRUE}.This makes sense % if the number of independent variables is very small. % If \code{solvesigma=FALSE} then the variance parameter is % treated as any other parameter to be estimated. % Default: \code{FALSE}. % } \item{\code{ratiotest_approx}}{logical. if \code{TRUE} the approximative formula that twice the difference of the likelihoods follow about a \eqn{\chi^2} distribution is used. The parameter of freedom equals the number of parameters to be estimated for the covariance function, including those for the covariates. Default: \code{TRUE} } \item{\code{reoptimise}}{logical. If \code{TRUE && !only_users} then at a very last step, the optimisation is redone with currently best parameters and likelihood as scale parameter for \command{\link{optim}}. Default: \code{TRUE}. } \item{\code{scale_max_relative_factor}}{ If the initial scale value for the ML estimation obtained by the LSQ target function is less than \eqn{(minimum distance between different pairs of points) / } \code{scale_max_relative_factor} a warning is given that probably a nugget effect is present. Note: if \code{scale_max_relative_factor} is greater than \code{lowerbound_scale_ls_factor} then no warning is given as the scale has the lower bound \eqn{(minimum distance between different pairs of points) / } \code{lowerbound_scale_ls_factor}. Default: \code{1000} } \item{\code{scale_ratio}}{ \command{\link{RFfit}} uses \code{parscale} and \code{fnscale} in the calls of \command{\link{optim}}. As these arguments should have the magnitude of the estimated values, \command{\link{RFfit}} checks this by calculating the absolute log ratios. If they are larger than \code{scale_ratio}, \code{parscale} and \code{fnscale} are reset and the optimisation is redone. Default: \code{0.1}. } \item{\code{shortnamelength}}{ The names of the variables in the returned table are abbreviated by taking the first \code{shortnamelength} letters. Default: \code{4}. } % \item{\code{sill}}{ currently not maintained anymore. % Additionally to estimating \code{nugget} and \code{variance} % separately, they may also be estimated together under the % condition that \code{nugget} + \code{variance} = \code{sill}. % For the latter a finite value for \code{sill} has to be supplied, % and \code{nugget} and \code{variance} are set to \code{NA}. % % \code{sill} is only used for the standard model. % % Default: \code{NA}. % } \item{\code{smalldataset}}{ If the number of locations is considered as small, then some more data are kept in the storage to accelerate the estimation algorithm. Default: \code{2000}. } \item{\code{split}}{integer. If the number of parameters to be numerically optimised is larger than or equal to \code{split} then \command{\link{RFfit}} checks whether a space-time covariance model or a multivariate covariance model can be split into components, so that certain parameters can be estimated separately. Default: \code{4}. } \item{\code{cliquesize}}{integer. \command{\link{RFfit}} tries to split the data set into parts of size splitn_neighbours[2] or less, but never more than \code{splitn_neighbours[3]} and never less than splitn_neighbours[1]. Default: \code{c(200, 1000, 3000)}. } \item{\code{splitfactor_neighbours}}{ The total number of neighbouring boxes in each direction \eqn{1 + 2\code{splitfactor}}, including the current box itself. Default: \code{2}. } \item{\code{split_refined}}{logical. If \code{TRUE} then also submodels are fitted if splitted. This takes more time, but \command{\link[=anova.RF_fit]{anova}} and \command{\link{RFratiotest}}, for instance, will give additional information. Default: \code{TRUE}. } \item{\code{upperbound_scale_factor}}{ The upper bound for the scale is determined as \code{upperbound_scale_factor} * (maximum distance between all pairs of points). Default: \code{3}. } \item{\code{upperbound_var_factor}}{ The upper bound for the variance and the nugget is determined as \code{upperbound_var_factor} * var(\code{data}) Default: \code{10}. } \item{\code{use_naturalscaling}}{ logical. Only used if model is given in standard (simple) way. If \code{TRUE} then \emph{internally}, rescaled covariance functions will be used for which cov(1)\eqn{\approx}{~=}0.05. \code{use_naturalscaling} has the advantage that \code{scale} and the form parameters of the model get \sQuote{orthogonal}, but \code{use_naturalscaling} does not work for all models. Note that this argument does not influence the output of \command{\link{RFfit}}: the parameter vector returned by \command{\link{RFfit}} refers \emph{always} to the standard covariance model as given in \command{\link{RMmodel}}. (In contrast to \code{practicalrange} in \command{\link{RFoptions}}.)\cr Advantages if \code{use_naturalscaling=TRUE}: \itemize{ \item \code{scale} and the shape parameter of a parameterised covariance model can be estimated better if they are estimated simultaneously. \item The estimated bounds calculated by means of \code{upperbound_scale_factor} and \code{lowerbound_scale_factor}, etc. might be more realistic. \item in case of anisotropic models, the inverse of the elements of the anisotropy matrix should be in the above bounds. } Disadvantages if \code{use_naturalscaling=TRUE}: \itemize{ \item For some covariance models with additional parameters, the rescaling factor has to be determined numerically. Then, more time is needed to perform \command{\link{RFfit}}. \item note the \code{use_naturalscaling} only affects simple models, no operators. Also functions that define a parameter of the model are not changed. } Default: \code{FALSE}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{9. \code{gauss}: Options for simulating Gaussian random fields} \describe{ \item{\code{approx_zero}}{ Value below which a correlation is considered to be essentially zero. This argument is used to determine the practical range of covariance function with non-compact support. Default: \code{0.05} } \item{\code{boxcox}}{ real vector of one or two components. If the first component is \code{Inf} then no transformation is performed. Otherwise the BoxCox transformation is performed. Note that Box Cox only works in a Gaussian framework. Note further that either \code{boxcox} or \code{loggauss} may be given. Default \code{c(Inf, 0)} } \item{\code{direct_bestvar}}{integer. When searching for an appropriate simuation method the matrix decomposition method (\code{method="direct"}) is preferred if the number of variables is less than or equal to \code{direct_bestvariables}. Default is \code{1200}. } \item{\code{loggauss}}{ logical. Whether a log-Gauss random fields should be returned. See also \code{boxcox} for a generalisation. } \item{\code{paired}}{ (\dQuote{Antithetic pairs}.) Logical. If \code{TRUE} then the second half of the simulations is logical. If \code{TRUE} then the second half of the simulations is obtained by only changing the signs of all the standard Gaussian random variables, on which the first half of the simulations is based. Default is \code{FALSE}. } \item{\code{stationary_only}}{ See \command{\link{RPgauss}} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{10. \code{graphics}: Options for graphical output} \describe{ \item{\code{always_close_device}}{logical. If \code{FALSE} the current device is kept as it is; otherwise the current device is closed before the next device is opened. If \code{NA} it closes the preceding device if the opened device is pdf or jpeg. Default: \code{NA}. } \item{\code{always_open_device}}{logical. If \code{TRUE} a new graphical window is opened for every \command{\link[graphics]{plot}} if a standard graphical output is used, trying to respect the aspect ratios for the plots. The devices pdf and jpeg are always opened. If \code{NA} then the value is set to \code{\link[base]{interactive}()}. Default: \code{TRUE}. } \item{\code{close_screen}}{logical; only relevant if \code{split_screen = TRUE} and \code{always_close_screen = FALSE}. If \code{FALSE} the windows opened by \command{\link[graphics]{split.screen}} are left open. Default: \code{TRUE}. } \code{file}{character; only relevant if \code{split_screen = TRUE}. argument \code{file} in \command{\link{pdf}} If \code{""} then no internal naming is performed. Default: \code{""}. } \item{\code{filenumber}}{integer; only relevant if \code{split_screen = TRUE}. Starting number of the file if \code{onefile=FALSE}. It is set to 0 whenever \code{file} is changed and \code{onefile=FALSE}. Default 0. } \item{\code{grDefault}}{ logical. If \code{FALSE} the graphic style up to Version 3.2 is used. Otherwise, the changes of th graphical style are reduced to a minimum. Default: \code{FALSE} } \item{\code{grPrintlevel}}{ integer values 0, 1, 2; only relevant when simulations are plotted. The higher the more text is shown in the plot. Default: \code{1}. } \item{\code{height}}{real number; only relevant if a new device is opened, see \code{alwyas_open_screen}. \itemize{ \item \code{height=NA} or \code{height} is not positive: no device is opened. \item \code{width = NA} If \code{height} is greater than zero then it gives the height of a single figure in a plot created by \pkg{RandomFields}; See also \code{close_screen}. If plots with multiple figures are shown, the height and width of the plot will be increased by a factor up the ones given by \code{increase_upto}. The width is calculated so that the aspect ratio is correct. \item \code{width} not \code{NA} \code{height} and \code{width} give the size of the whole window. } Default: \code{6}. } \item{\code{increase_upto}}{ See \code{height}. Default: \code{c(3,4)}. } \item{\code{split_screen}}{logical. If \code{TRUE} \command{\link[graphics]{split.screen}} is used to split the screen. Otherwise \code{par(mfcol)}. When using \code{split_screen} then the figures tend to be fancier. Default: \code{TRUE}. } \item{\code{onefile}}{logical; only relevant if \code{split_screen = TRUE}. About the behaviour of argument \code{onefile} in \command{\link{pdf}} Default: \code{FALSE}. } \item{\code{width}}{real number or NA; only relevant if \code{always_open_screen=TRUE}. See \code{height} for details. Default: \code{NA}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{11. \code{gui}: Options for c\command{\link{RFgui}}} \describe{ \item{\code{alwaysSimulate}}{ logical. If \code{TRUE} then a new random field is simulated whenever a parameter is changed. Otherwise only the covariance function or the variogram is re-plotted; simulations are performed only when the correponding button is pressed. Default: \code{TRUE}. } \item{\code{simu_method}}{ \code{"RPcirculant"}, \code{"RPcutoff"}, \code{"RPintrinsic"}, \code{"RPtbm"}, \code{"RPspectral"}, \code{"RPdirect"}, \code{"RPsequential"}, \code{"RPaverage"}, \code{"RPnugget"}, \code{"RPcoins"}, \code{"RPhyperplane"}, \code{"RPspecific"}, \code{"any method"}. Default: \code{"RPcirculant"}. } \item{\code{size}}{vector of 2 components. Grid size of the simulated stochastic processes. The two components of the vector correspond to one-dimensional and two-dimensional processes, respectively. Default: \code{c(1024, 64)}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{12. \code{hyper}: Options for simulating hyperplane tessellations} \describe{ \item{\code{mar_distr}}{integer. This argument should not be changed yet. It codes the marginal distribution used in the simulation: 0 : uniform distribution\cr 1 : Frechet distribution with form argument \code{mar_param}\cr 2 : Bernoulli distribution (Binomial with \eqn{n=1}) with argument \code{mar_param} Default: \code{0} . } \item{\code{mar_param}}{Argument used for the marginal distribution. The argument should not be changed yet. Default: \code{NA} . } \item{\code{maxlines}}{integer. Maximum number of allowed lines. Default: \code{1000} . } \item{\code{superpos}}{integer. number of superposed hyperplane tessellations. Default: \code{300} . } } \bold{13. \code{krige}: Options for Kriging} \describe{ \item{\code{cholesky_R}}{ obsolete } \item{\code{fillall}}{ logical value for imputing. If true all the components are estimated whether they are \code{NA} or not. Default: \code{TRUE}. } \item{\code{locmaxn}}{ Kriging is conditions on maximal \code{locmaxn} points. If the data contain more points, neighbourhood kriging is performed. Default: \code{8000}. } \item{\code{locsplitfactor}}{ In case of neighbourhood kriging, the area is split into small boxes. The complete neighbourhood contains (2 * \code{locsplitfactor} +1) boxes in each direction. Default: \code{2}. } % \item{\code{locsplitn}}{vector of 3 components. % A box should contain no more than \code{locsplitn[1]} % points, but never less than \code{locsplitn[2]}. If % a box had originally less than \code{locsplitn[2]} points, % then the box is increased until at least \code{locsplitn[3]} % points are in the box. } \item{\code{locsplitn}}{vector of 3 components. A box should contain no more than \code{locsplitn[3]} points, but never less than \code{locsplitn[1]}. If a box had originally less than \code{locsplitn[1]} points, then the box is increased until at least \code{locsplitn[2]} points are in the box. Default: \code{c(200, 1000, 5000)}. } \item{\code{method}}{ obsolete } \item{\code{return.variance}}{logical. If \code{FALSE} the kriged field is returned. If \code{TRUE} a list of two elements, \code{estim} and \code{var}, i.e. the kriged field and the kriging variances, is returned. Default: \code{FALSE}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{14. \code{maxstable}: Options for simulating max-stable random fields} \describe{ % extreme \item{\code{check_every}}{ integer. In order to get a precise simulation result, by definition, the maximum must be taken, for each shape function, over alle locations of interest. Clearly, small values will not play a role. To this end, the global minimum has to be determined. The calculation of the global minimum is expensive and therefor should not be done too frequently. On the other hand, rare updates increases the computing times for taking the maximum over a single shape functions. Here, after every \code{check_every} considered shape function, the global minimum is calculated. It is expected that a good choice for \code{check_every} is in in the interval \eqn{[10, 100]}. (For ease and for concerns of efficiency, the more adequate, local minimum is not considered.) Default: 30 . } \item{\code{density_ratio}}{ value in \eqn{[0,1]}. This argument is considered only if \code{flat=-1} and the simulation is performed on a grid. Then, the ratio between the highest and the lowest value is calculated within the convex hull of the grid. If the value is less than \code{density_ratio} then the grid points are considered separately. Else the density is considered to be constant in the convex hull of the grid. Default: 0.0. } \item{\code{eps_zhou}}{positive real number, which gives the aimed relative precision when the constant \eqn{c} in the paper of Oesting, Schlather, Zhou (2018) has to be estimated. E.g. if \code{eps_zhou=0.01} then the first 2 digits should be correct. Default: 0.01 } \item{\code{flathull}}{\code{NA, FALSE, TRUE}. Only used in M3 modelling in the algorithm by Oesting, Schlather, Zhou (2018). The argument is considered only if the simulation is performed on a grid. If \code{flat=TRUE} , then the density is considered to be \code{flat} in the convex hull of the grid, i.e. the simulation method of Schlather (2002) is used. If \code{flat=NA} the choice is done automatically. Default: FALSE . } \item{\code{max_gauss}}{ The simulation of the max-stable process by the old-fashioned method of Schlather (2002) and by older methods for Brown-Resnick processes uses a stopping rule that necessarily needs a finite upper endpoint of the marginal distribution of the random field. In the case of \command{\link[=RPbrownresnick]{Brown-Resnick processes}}, \command{\link[=RPschlather]{extremal Gaussian fields}}, and \command{\link[=RPopitz]{extremal t fields}}, the upper endpoint is approximated by \code{standardmax}. Default: \code{3.0} . } \item{\code{max_n_zhou}}{positive integer. The overall constant \eqn{c} in the paper of Oesting, Schlather, Zhou (2018) has to be determined by MCMC, if the shape functions are random. The two arguments, \code{min_n_zhou} and \code{max_n_zhou}, give the minimal and the maximal number of simulations that are performed. To economize computer time the values of \eqn{c} is partially estimated when the shape functions are simulated. If the number of shape functions is larger than the number of simulations given by \code{eps_zhou} then no further simulation is performed to determine \eqn{c}. So, it is advantageous to simulate all fields at once by \code{RFsimulate(..., n = )}. Default: 1000 and 10000000, respectively. } \item{\code{maxpoints}}{ positive integer; the maximal number of Poisson points to be simulated for one realization of the max-stable random field. This option will not be considered for most of the users. This option allows the simulation to interrupt after \code{maxpoints} shape function have been placed. Default: \code{2e9} (never). } \item{\code{mcmc_zhou}}{positive integer. In case of random shape functions, an MCMC step is required. \code{mcmc_zhou}-1 equals the number of members of the MCMC chain that are left out before the next value of the chain is returned. Default: 20 } \item{\code{min_n_zhou}}{see \code{max_n_zhou}} \item{\code{mcmc_zhou}}{positive integer. In case of random shape functions, an MCMC step is required. \code{mcmc_zhou}-1 equals the number of members of the MCMC chain that are left out before the next value of the chain is returned. Default: 20 } \item{\code{min_n_zhou}}{see \code{max_n_zhou}} \item{\code{min_shape_gumbel}}{To increase speed, the minimum field value is assumed to be \code{min_shape_gumbel} for calculation of threshold values for simulation short cuts. During a simulation, its value becomes void as soon as the real (current) minimum of the field being simulated exceeds \code{min_shape_gumbel} % values of shape % functions smaller than \code{min_shape_gumbel} are considered as % being zero. Necessarily, the shape function must be essentially % isotropic and decreasing with known inverse function. Default: \code{-1e15}. } \item{\code{scatter_method}}{logical. If Default: NA; } \item{\code{xi}}{ Extreme value index. Default: \code{2e9} . While \eqn{\xi} can be set globally, the shift \eqn{\mu} and the scale \eqn{s} can be given only locally within the process definitions, e.g., \command{\link{RPsmith}}. Default: \code{1.0}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{15. \code{mpp}: Options for the random coins (shot noise) methods} \describe{ \item{\code{about_zero}}{ In certain cases (\link{Coins},\link{RMtruncsupport}), functions are assumed to zero if the value is less than \code{about_zero}. Default: \code{0.001} . } \item{\code{n_estim_E}}{integer. Number of draws from the distribution of the scale to estimate the mean of the distribution. This is used only if the mean of the scale distribution is not explicitely given. Default: \code{50000} . } \item{\code{scatter_method}}{ } \item{\code{scatter_size}, \code{scatter_max}}{ Real valued and integer valued, respectively, or \code{NA}. Used in the internal function \code{RMscatter} that calculates \eqn{\sum_{i=1}^n f(x + h_i)} for some function \eqn{f} and for some distances \eqn{h_i}. % see \code{size} and \code{max} in \code{\link{RMscatter}}. Let \eqn{\varepsilon=}\code{about_zero}, \eqn{s=}\code{scatter_size} and \eqn{m=}\code{scatter_max}. We distinguish 4 cases: \itemize{ \item \code{scatter_size > 0} and \code{scatter_max >= 0}\cr Here, \eqn{n} equals \eqn{(2m)^d}. and \eqn{h_i \in M = \{ (k s, \ldots, k s),\ldots, (m s, \ldots, m s)\}} with \eqn{k=-m}. \item \code{scatter_size > 0} and \code{scatter_max < 0}\cr same as the previous case, but \eqn{m} is chosen such that \eqn{f(k_i e_i s_i) \approx \varepsilon}, \eqn{-k_i\in N}, \eqn{i=1,\ldots,d} and \eqn{f(m_i e_i s_i) \approx \varepsilon}, \eqn{m \in N}. \item \code{scatter_size <= 0} and \code{scatter_max >= 0}\cr This option is possible only for grids. Here \eqn{h_i} runs on the given grid \eqn{i=1,\ldots,d}, but at most \code{scatter_max} steps. \item \code{scatter_size <= 0} and \code{scatter_max < 0}\cr this option is possible only for grids. Here, \eqn{h_i} runs over the whole grid. } } \item{\code{shape_power}}{ Shape functions are powered by \code{shape_power} before used as intensity function for the point process. Default: \code{2.0}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{16. \code{nugget}: Options for the nugget effect}\cr Simulating a nugget effect is per se trivial. However, it gets complicated and best methods (including \code{direct} and \code{circulant embedding}!) fail if zonal anisotropies are considered, where sets of points have to be identified that belong to the same subspace of eigenvalue 0 of the anisotropy matrix. \describe{ \item{\code{tol}}{ The nugget tolerance influences two different kind of models \itemize{ \item \command{\link{RPnugget}} \item \command{\link{R.is}} } See there for more information. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{17. \code{registers}: Register numbers}\cr Model for different purposes are or can be stored at different places. They are called registers and have non-negative numbers up to 21 (currently). The user can use the registers 0..9. \describe{ \item{\code{register}}{number in 0:9; place where intermediate calculation for random field simulation are stored; the number refers to 10 internal registers 0..9. Changing the register number only makes sense, when two different random fields, say, are to be simulated alternatingly, several times in a row. Then the simlulation speed can be increased if several registers are used, \code{storing=TRUE} and \command{\link{RFsimulate}} is used with the only argument \code{n}. Default: \code{0} %[also do]. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{18. \code{sequ}: Options for the sequential method} \describe{ \item{\code{back_steps}}{See \command{\link{RPsequential}}} \item{\code{initial}}{See \command{\link{RPsequential}}} \item{\code{max_variables}}{See \command{\link{RPsequential}}} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{19. \code{solve}: Options for solving linear systems} \describe{ \item{\code{det_as_log}}{\RFU } \item{\code{eigen2zero}}{\RFU } \item{\code{max_chol}}{integer. Maximum number of rows of a matrix in a Cholesky decomposition Default: \eqn{8192} } \item{\code{max_svd}}{integer. Maximum number of rows of a matrix in a svd decomposition Default: \eqn{6555} } \item{\code{pivot}}{Type of pivoting for the Cholesky decomposition. Possible values are \describe{ \item{PIVOT_NONE}{No pivoting.} \item{PIVOT_AUTO}{If the matrix has a size greater than 3x3 and Choleskey fails without pivoting, privoting is done. For matrices of size less than 4x4, no pivoting and no checks are performed.} \item{PIVOT_DO}{Do alwaoys pivoting. NOTE: privoted Cholesky decomposition yields only very approximately an upper triangular matrix L, but still L^t L = M holds true.} \item{PIVOT_IDX}{uses the same pivoting as in the previous pivoted decomposition. This option becomes relevant only when simulations with different parameters or different models shall be performed with the same seed so that also the pivoting must be coupled. } % \item{PIVOT_IDXBACK}{ same as \code{PIVOT_IDX}, but % the sequence of indices of the pivoting is returned via % \code{RFoptions()$solve$pivot_idx}.} } Default: \code{PIVOT_auto}} \item{\code{pivot_actual_size}}{\RFU } \item{\code{pivot_check}}{logical. Only used in pivoted Cholesky decomposition. If \code{TRUE} and a numerically zero diagonal element is detected, it is checked whether the offdiagonal elements are numerically zero as well. (See also \code{pivot_max_deviation} and \code{pivot_max_reldeviation}.) if \code{NA} then, in \link{RPdirect}, the value is equivent to \describe{ \item{\code{FALSE}}{if the model is positive (semi-)definite.} \item{\code{TRUE}}{if the model is genuinely negative definite.} } Default: \code{NA} } \item{\code{pivot_idx}}{\RFU} \item{\code{pivot_relerror}}{\RFU } \item{\code{pivot_max_deviation}}{\RFU } \item{\code{pivot_max_reldeviation}}{\RFU } \item{\code{solve_method}}{\RFU } \item{\code{spam_factor}}{\RFU } \item{\code{spam_min_n}}{\RFU } \item{\code{spam_min_p}}{\RFU } \item{\code{spam_pivot}}{\RFU} \item{\code{spam_sample_n}}{\RFU} \item{\code{spam_tol}}{\RFU} \item{\code{svdtol}}{\RFU} \item{\code{use_spam}}{\RFU} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{20. \code{special}: Options for specific methods} \describe{ \item{\code{multicopies}}{Only used by \command{\link{RMmult}}. The covariance functions are multiplied if the corresponding independent random fields are multiplied. To get an approximative Gaussian random fields with a multiplicative covariance functions the average over \code{multicopies} products of random fields is calculated. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{21. \code{spectral}: Options for the spectral (turning bands) method} \describe{ \item{\code{ergodic}}{ In case of an additive model and \code{ergodic=FALSE}, the additive component are chosen proportional to their variance. In total \code{lines} are simulated. If \code{ergodic=TRUE}, the components are simulated separately and then added. Default: \code{FALSE}. } \item{\code{prop_factor}}{see \command{\link{RPspectral}} } \item{\code{sigma}}{see \command{\link{RPspectral}} } \item{\code{sp_grid}}{ see \command{\link{RPspectral}} } \item{\code{sp_lines}}{ see \command{\link{RPspectral}} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{22. \code{tbm}: Options for the turning bands method} \describe{ \item{\code{center}}{Scalar or vector. If not \code{NA}, the \code{center} is used as the center of the turning bands for \code{TBM2} and \code{TBM3}. Otherwise the center is determined automatically such that the line length is minimal. See also \code{points} and the examples below. Default: \code{NA} . } \item{\code{fulldim}}{ positiv integer. The dimension of the space into which the simulated field is embedded. So, the value \code{fulldim} must be at least the dimension of the field. Default: 3. } \item{\code{grid}}{Logical. The angle of the lines is random if \code{grid=FALSE}, and \eqn{k\pi/}{k*pi/}\code{lines} for \eqn{k}{k} in \code{1:lines}, otherwise. This option is used by both \command{\link{RPspectral}} and \command{\link{RPtbm}}, the latter only when the dimension is 2. Default: \code{TRUE} . } \item{\code{layers}}{ Logical or integer. If \code{TRUE} then the turning layers are used whenever a time component is given. If \code{NA} the turning layers are used only when the traditional TBM is not applicable. If \code{FALSE} then turning layers may never be used. Default: \code{TRUE} . } \item{\code{lines}}{ Number of lines used. Default: \code{60} . } \item{\code{linesimustep}}{ If \code{linesimustep} is positive the grid on the line has lag \code{linesimustep}. See also \code{linesimufactor}. Default: \code{0.0} . } \item{\code{linesimufactor}}{ \code{linesimufactor} or \code{linesimustep} must be non-negative; if \code{linesimustep} is positive then \code{linesimufactor} is ignored. If both arguments are naught then \code{points} is used (and must be positive). The grid on the line is \code{linesimufactor}-times finer than the smallest distance. See also \code{linesimustep}. Default: \code{2.0} . } \item{\code{points}}{integer. If greater than 0, \code{points} gives the number of points simulated on the TBM line, hence must be greater than the minimal number of points given by the size of the simulated field and the two paramters \code{TBMx.linesimufactor} and \code{TBMx.linesimustep}. If \code{points} is not positive the number of points is determined automatically. The use of \code{center} and \code{points} is highlighted in an example below. Default: \code{0}. } \item{\code{reduceddim}}{ if positiv integer, then the value itself. If negativ, then the value is substracted from fulldim. Default: \code{-2}. } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bold{23. \code{internal}: Internal options mostly for warnings and messages} All these options should not be changed by the user unless he/she really known what he/she is doing. Most of the options below change their value in a session without the user's notice. \describe{ \item{\code{do_tests}}{ Internal variable. Do not use it. Default: \code{FALSE}. } \item{\code{examples_reduced}}{non-negative integer. If positve, then the design of any simulation in \pkg{RandomFields} is internally reduced in size (roughly downto the given value in each direction). Warnings report this behaviour. This option is necessary to run the examples of \pkg{RandomFields} under the time constraint of CRAN. } \item{\code{stored.init}}{internally used logical argument. This option is closely related to \code{storing} which controls whether intermediate calculations should be stored to have faster repeated simulations. This user option is internally overwritten if the user calls several simulations at once. This current value is stored in \code{stored.init}. Default: \code{FALSE}. } \item{\code{warn_ambiguous}}{internally used logical argument. Usually, the argument \code{grid} in \command{\link{RFsimulate}}, for instance, can or should be given. If not given, the system takes a default definition. Additionally a message is displayed in this case if \code{ambiguous=TRUE}. Default: \code{FALSE}. } \item{\code{warn_aspect_ratio}}{internally used logical argument. if \code{TRUE} then a warning is given not a standard graphical device is used and the package plots try to keep a certain aspect ratio. Default: \code{TRUE} } \item{\code{warn_colour_palette}}{internally used logical argument. If none of the packages \pkg{RColorBrewer} and \pkg{colorspace} are available and graphics are displayed, a message is displayed. Default: \code{TRUE}. } \item{\code{warn_constant}}{ The definition of \command{\link{RMconstant}} has changed. A warning is displayed if the command is used. \code{warn_constant} will become obsolete in future versions. Default: \code{TRUE}. } \item{\code{warn_coordinates}}{internally used logical argument. If \code{TRUE} then a transformation from earth coordinates to cartesian coordinates is reported. Default: \code{TRUE}. } \item{\code{allow_duplicated_locations}}{logical. If \code{FALSE} duplicated locations are not allowed. If \code{TRUE} then the (standard) nugget effect becomes a non-stationary model in an abstract space that cannot be extended outside the given locations. See also \link{RMnugget} for the distinction between measurement error and spatial nugget. Default: \code{FALSE}. } \item{\code{warn_missing_zenit}}{ % to do Only for Earth systems: a missing zenit is frequently a cause for errors that are difficult to understand. Therefore, in such cases an additional warning message is displayed. Default: \code{TRUE} } \item{\code{warn_newAniso}}{ obsolete.\cr internally used logical argument. If \code{newAniso=TRUE} and the argument \code{Aniso} is used in the model definition, then a message is displayed that the matrix \code{Aniso} is multiplied from the right by \eqn{x}, where up to Version 2.0 the argument \code{aniso} was available which was multiplied from the left by \eqn{x}. Default: \code{TRUE}. } % \item{\code{warn_new_definitions}}{internally used logical argument. % If \code{warn_new_defintions=TRUE} then a warning is returned when % models are used whose definition has changed recently. % %Default: \code{TRUE}. % } \item{\code{warn_newstyle}}{internally used logical argument. If \code{TRUE} a message is displayed the by the argument \code{spConform=FALSE} oldstyle return values are obtained instead of S4 objects. Default: \code{TRUE}. } \item{\code{warn_normal_mode}}{internally used logical argument. if \code{TRUE} then the function \command{\link{RFfit}} displays the message that other values for the option \code{modus_operandi} are available. Default: \code{TRUE}. } \item{\code{warn_oldstyle}}{internally used logical argument. If \code{TRUE} a warning is given if an obsolete function from Version 2 is used. Default: \code{TRUE}. } \item{\code{warn_on_grid}}{internally used logical argument. If a (one-dimensional) grid is given, but the argument \code{grid=FALSE}, e.g. in \code{RFsimulate}, this contraction is reported if \code{warn_on_grid=TRUE} Default: \code{TRUE}. } \item{\code{warn_scale}}{internally used logical argument. If \code{warn_scale=TRUE} then a scale less than 10 [km] is reported if earth coordinates are transformed to cartesian coordinates. Default: \code{TRUE}. } \item{\code{warn_var}}{ In some cases, \pkg{RandomFields} cannot detect whether the variance is non-negative. If \code{TRUE} then a warning is displayed in such a case. Default: \code{TRUE}. } } %\bold{General comments}\cr %Most of the above arguments determine the basic settings of a %simulation, e.g. \code{matrix_method} (which chooses the method to %calculate a square %root of a positive definite matrix). The values of %such arguments are read by %\command{\link{RFsimulate}} and stored in an internal register %and used in preliminary, deterministic calculations (e.g. calculation %of the square of a covariance matrix) %Some few other arguments like \code{lines} (which determines the number of %i.i.d. processes to be simulated on the line) %are only relevant when generating %random numbers. %These arguments are read only when actually simulations are performed, and %are marked by \dQuote{[do]}. %The difference of these two classes of arguments might become %important only if\code{general.storing = TRUE} and %\command{\link{RFsimulate}} is called with the only argument %\code{n}. } \section{Value}{ \code{NULL} if any argument is given, and the full list of arguments, otherwise. } \references{ \itemize{Basic} \itemize{ \item General \itemize{ \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. % \item Schlather, M. (2002) Models for stationary max-stable } \item rectangular distribution; \code{eps_zhou} \itemize{ \item Oesting, M., Schlather, M. and Zhou, C. (2013) On the Normalized Spectral Representation of Max-Stable Processes on a compact set. \emph{arXiv}, \bold{1310.1813} } \item \code{shape_power} \itemize{ \item Ballani, F. and Schlather, M. (2015) In preparation. } } } \me \seealso{\command{\link{RFsimulate}}, \link{RFoptionsAdvanced}, \code{\link[RandomFieldsUtils]{RFoptions}}, and \command{\link{RFgetMethodNames}}.} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions() ############################################################ ## ## ## use of exactness ## ## ## ############################################################ x <- seq(0, 1, 1/30) model <- RMgauss() for (exactness in c(NA, FALSE, TRUE)) { readline(paste("\n\nexactness: `", exactness, "'; press return")) z <- RFsimulate(model, x, x, exactness=exactness, stationary_only=NA, storing=TRUE) print(RFgetModelInfo(which="internal")$internal$name) } \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMuser.Rd0000644000176200001440000001162713437301604015110 0ustar liggesusers\name{RMuser} \alias{RMuser} \alias{RM_USER} \title{User-Defined Function} \description{ \command{RMuser} allows for a user-defined covariance function, variogram model, or arbitrary function. \bold{RMuser is very slow -- users should avoid this model whenever possible.} } \usage{ RMuser(type, domain, isotropy, vdim, beta, coordnames = c("x", "y", "z", "T"), fctn, fst, snd, envir, var, scale, Aniso, proj) } \arguments{ \item{type}{ See \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}} for the range of values of the arguments. Default: \code{"shape function"}. } \item{domain}{ See \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}} for the range of values of the arguments. Default: \code{XONLY}. } \item{isotropy}{See \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}} for the range of values of the arguments. Default: \itemize{ \item \code{'isotropic'} if \code{type} equals \code{'tail correlation function'}, \code{'positive definite'} or \code{'negative definite'}; \item \code{'cartesian system'} if \code{type} indicates a process or simulation method or a shape function. } } \item{vdim}{multivariability. Default: \code{vdim} is identified from \code{beta} if given; otherwise the default value is \code{1}. } \item{beta}{a fixed matrix that is multiplied to the return value of the given function; the dimension must match. Defining a vector valued function and \code{beta} as a vector, an arbitrary linear model can be defined. Estimation of \code{beta} is, however, not established yet. } \item{coordnames}{ Just the names of the variables. More variable names might be given here than used in the function. See Details for the interpretation of variables. } \item{fctn, fst, snd}{a user-defined function and its first, second and third derivative, given as \code{quote(myfunction(x))} or as \code{quote(myfunction(x, y))}, see Details and Examples below. } \item{envir}{the environment where the given function shall be evaluated} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Primarily, a function is expected that depends on a vector whose components, \eqn{x, y, z, T}, are given separately as scalar quantities. Alternatively, the function might depend only on the first argument given by \code{coordnames}. A kernel should depend on the first two arguments given by \code{coordnames}. } \value{ \command{\link{RMuser}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ \itemize{ \item The use of \command{RMuser} is completely on the risk of the user. There is no way to check whether the expressions of the user are correct in any sense. \item Note that \code{x}, \code{y}, \code{z} and \code{T} are reserved argument names that define solely the coordinates. Hence, none of these names might be used for other arguments within these functions. \item In user-defined functions, the models of \pkg{RandomFields} are not recognized, so they cannot be included in the function definitions. \item \command{\link{RMuser}} may not be used in connection with obsolete commands of RandomFields. } } \me \seealso{ \command{\link{RMcovariate}}, \command{\link{RMfixcov}}, \command{\link{RFfit}}, \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \link{RC_ISO_NAMES}, \link{RC_DOMAIN_NAMES}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Alternatively to 'model <- RMexp()' one may define the following ## (which is, however, much slower and cannot use all features of ## RandomFields) \dontshow{if (RFoptions()$general$storing) { cat("This examples requires 'RFoptions(storing=FALSE)', what is set now.\n"); RFoptions(storing=FALSE) }} ## user-defined exponential covariance model model <- RMuser(type="positive definite", domain="single variable", iso="isotropic", fctn=exp(-x)) x <- y <- seq(1, 10, len=100) plot(model) z <- RFsimulate(model, x=x, y=y) plot(z) ## the kernel, which is the scalar product (see RMprod) model <- RMnugget(var=1e-5) + RMuser(type="positive definite", domain="kernel", iso="symmetric", fctn=sum(x * y)) x <- y <- seq(1, 10, len=35) z <- RFsimulate(model, x=x, y=y, n=6, svdtol=1e-9) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMmodel-class.Rd0000644000176200001440000001735713437301604016343 0ustar liggesusers\name{RMmodel-class} \docType{class} \alias{RMmodel-class} \alias{show,RMmodel-method} \alias{print.RMmodel} \alias{plot,RMmodel,missing-method} \alias{persp,RMmodel-method} \alias{image,RMmodel-method} \alias{points,RMmodel-method} \alias{lines,RMmodel-method} \alias{points.RMmodel} \alias{lines.RMmodel} \alias{str.RMmodel} \alias{[,RMmodel-method} \alias{[,RMmodel,ANY,ANY,ANY-method} \alias{[<-,RMmodel-method} \alias{[<-,RMmodel,ANY,ANY,ANY-method} \alias{+,RMmodel,RMmodel-method} \alias{+,numeric,RMmodel-method} \alias{+,logical,RMmodel-method} \alias{+,RMmodel,numeric-method} \alias{+,RMmodel,logical-method} \alias{*,RMmodel,RMmodel-method} \alias{*,numeric,RMmodel-method} \alias{*,logical,RMmodel-method} \alias{*,RMmodel,logical-method} \alias{*,RMmodel,numeric-method} \alias{-,RMmodel,RMmodel-method} \alias{-,numeric,RMmodel-method} \alias{-,logical,RMmodel-method} \alias{-,RMmodel,logical-method} \alias{-,RMmodel,numeric-method} \alias{/,RMmodel,RMmodel-method} \alias{/,numeric,RMmodel-method} \alias{/,logical,RMmodel-method} \alias{/,RMmodel,numeric-method} \alias{/,RMmodel,logical-method} \alias{^,RMmodel,RMmodel-method} \alias{^,numeric,RMmodel-method} \alias{^,logical,RMmodel-method} \alias{^,RMmodel,numeric-method} \alias{^,RMmodel,logical-method} \alias{c,RMmodel-method} \alias{RFplotModel} \title{Class \code{RMmodel}} \description{ Class for \pkg{RandomFields'} representation of explicit covariance models } \usage{ RFplotModel(x, y, dim=1, n.points=if (dim==1 || is.contour) 200 else 100, fct.type=NULL, MARGIN, fixed.MARGIN, maxchar=15, ..., plotmethod=if (dim==1) "matplot" else "contour") \S4method{plot}{RMmodel,missing}(x, y, ...) \S4method{points}{RMmodel}(x, ..., type="p") \S4method{lines}{RMmodel}(x, ..., type="l") \S4method{image}{RMmodel}(x, ..., dim=2) \S4method{persp}{RMmodel}(x, ..., dim=2, zlab="") } \arguments{ \item{x}{object of class \code{\link[=RFsp-class]{RFsp}} or \command{\link[=RFempVariog-class]{RFempVario}} or \command{\link[=RFfit-class]{RFfit}} or \command{\link[=RMmodel-class]{RMmodel}}; in the latter case, \code{x} can be any sophisticated model but it must be either stationary or a variogram model.} \item{y}{ignored in most methods} \item{MARGIN}{vector of two; two integer values giving the coordinate dimensions w.r.t. whether the field or the covariance model is to be plotted; in all other directions, the first index is taken.} % \item{MARGIN.slices}{integer value; if \eqn{[space-time-dimension>2]}, % \code{MARGIN.slices} can specify a third dimension w.r.t. which a % sequence of slices is plotted. Currently only works for grids.} \item{fixed.MARGIN}{only for \code{class(x)==CLASS_CLIST} and if \code{dim > 2}; a vector of length \code{dim}-2 with distance values for the coordinates that are not displayed.} \item{maxchar}{integer. Maximum number of characters to print the model in the legend. } \item{...}{arguments to be passed to methods; mainly graphical arguments, or further models in case of class \code{CLASS_CLIST}, see Details. } \item{dim}{must equal 1 or 2; only for \code{class(x)==CLASS_CLIST}; the covariance function and the variogram are plotted as a function of \eqn{\R^\code{dim}}{R^\code{dim}}.} \item{n.points}{integer; only for \code{class(x)==CLASS_CLIST}; the number of points at which the model is evaluated (in each dimension); defaults to 200.} \item{fct.type}{character; only for \code{class(x)==CLASS_CLIST}; must equal \code{NULL}, \code{"Cov"} or \code{"Variogram"}; controls whether the covariance (\code{fct.type="Cov"}) or the variogram (\code{fct.type="Variogram"}) is plotted; \code{NULL} implies automatic choice, where \code{"Cov"} is chosen whenever the model is stationary.} \item{plotmethod}{string or function. Internal. } \item{type}{character. See \command{\link[graphics]{points}}.} \item{zlab}{character. See \command{\link[graphics]{persp}}.} } \value{ If \code{RFoptions()$split_screen=TRUE} and \code{RFoptions()$close_screen=TRUE} then the \code{plot} functions return the \code{screen} numbers. Else \code{NULL}. } \section{Creating Objects}{ Objects are created by calling a function of class \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. } \section{Slots}{ \describe{ \item{\code{call}:}{language object; the function call by which the object was generated} \item{\code{name}:}{character string; nickname of the model, name of the function by which the object was generated} \item{\code{submodels}:}{list; contains submodels (if existent)} \item{\code{par.model}:}{list; contains model specific arguments} \item{\code{par.general}:}{list of 4; contains the four standard arguments \code{var}, \code{scale}, \code{Aniso} and \code{proj} that can be given for any model; if not specified by the user, the string \code{"RFdefault"} is inserted} } } %\section{Extends}{ %} \section{Methods}{ \describe{ \item{+}{\code{signature(x = CLASS_CLIST)}: allows to sum up covariance models; internally calls \command{\link{RMplus}}.} \item{-}{\code{signature(x = CLASS_CLIST)}: allows to substract covariance models; internally calls \command{\link{R.minus}}.} \item{*}{\code{signature(x = CLASS_CLIST)}: allows to multiply covariance models; internally calls \command{\link{R.mult}}.} \item{/}{\code{signature(x = CLASS_CLIST)}: allows to divide covariance models; internally calls \command{\link{R.div}}.} \item{c}{\code{signature(x = CLASS_CLIST)}: concatenates covariance functions or variogram models.} \item{plot}{\code{signature(x = CLASS_CLIST)}: gives a plot of the covariance function or of the variogram model; for more details see \command{\link{plot-method}}.} \item{points}{\code{signature(x = CLASS_CLIST)}: adds a covariance plot to an existing plot; for more details see \command{\link{plot-method}}.} \item{lines}{\code{signature(x = CLASS_CLIST)}: adds a covariance plot to an existing plot; for more details see \command{\link{plot-method}}.} \item{str}{\code{signature(x = CLASS_CLIST)}: as the usual \code{\link[utils]{str}}-method for S4 objects but only those entries of the 'par.general'-slot are shown that contain values different from \code{'RFdefault'}.} \item{show}{\code{signature(x = CLASS_CLIST)}: returns the structure of \code{x}.} \item{print}{\code{signature(x = CLASS_CLIST)}: identical with \command{show}-method, additional argument is \code{max.level}.} \item{[}{\code{signature(x = CLASS_CLIST)}: enables accessing the slots via the \code{"["}-operator, e.g. \code{x["par.general"]}.} \item{[<-}{\code{signature(x = CLASS_CLIST)}: enables replacing the slots via the \code{"["}-operator.} \item{\code{signature(x = CLASS_CLIST, y = "missing")}}{Generates covariance function or variogram function plots in one or two dimensions.} } } \section{Details}{ All the above arguments apply for all the S3 and S4 functions given here as they call \command{RFplotModel} immediately. } \author{Alexander Malinowski, \martin} \seealso{ \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}} \link{RMmodel} } \keyword{classes} \keyword{print} \keyword{hplot} \examples{\dontshow{StartExample()} # see RMmodel for introductory examples # Compare: model <- RMexp(scale=2) + RMnugget(var=3) str(model) ## S4 object as default in version 3 of RandomFields model <- summary(model) str(model) ## list style as in version 2 of RandomFields ## see also 'spConform' in 'RFoptions' to make this style ## the default \dontshow{FinalizeExample()}} RandomFields/man/RMmultiquad.Rd0000644000176200001440000000564513437301604016142 0ustar liggesusers\name{RMmultiquad} \alias{RMmultiquad} \alias{Poisson spline} \alias{Inverse multiquadric} \alias{multiquadric family} \title{The Multiquadric Family Covariance Model on the Sphere} \description{ \command{\link{RMmultiquad}} is an isotropic covariance model. The corresponding covariance function, the multiquadric family, only depends on the angle \eqn{\theta \in [0,\pi]}{0 \le \theta \le \pi} between two points on the sphere and is given by \deqn{\psi(\theta) = (1 - \delta)^{2*\tau} / (1 + delta^2 - 2*\delta*cos(\theta))^{\tau}}{\psi(\theta) = (1 - \delta)^{2*\tau} / (1 + delta^2 - 2*\delta*cos(\theta))^{\tau},} where \eqn{\delta \in (0,1)}{0 < \delta < 1} and \eqn{\tau > 0}{\tau > 0}. } \usage{ RMmultiquad(delta, tau, var, scale, Aniso, proj) } \arguments{ \item{delta}{a numerical value in \eqn{(0,1)}} \item{tau}{a numerical value greater than \eqn{0}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Special cases (cf. Gneiting, T. (2013), p.1333) are known for fixed parameter \eqn{\tau=0.5}{\tau=0.5} which leads to the covariance function called 'inverse multiquadric'\deqn{\psi(\theta) = (1 - \delta) / \sqrt( 1 + delta^2 - 2*\delta*cos(\theta) )}{\psi(\theta) = (1 - \delta) / \sqrt( 1 + delta^2 - 2*\delta*cos(\theta) )} and for fixed parameter \eqn{\tau=1.5}{\tau=1.5} which gives the covariance function called 'Poisson spline' \deqn{\psi(\theta) = (1 - \delta)^{3} / (1 + delta^2 - 2*\delta*cos(\theta))^{1.5}}{\psi(\theta) = (1 - \delta)^{3} / (1 + delta^2 - 2*\delta*cos(\theta))^{1.5}.} For a more general form, see \command{\link{RMchoquet}}. } \value{ \command{\link{RMmultiquad}} returns an object of class \command{\link[=RMmodel-class]{RMmodel}}. } \references{ Gneiting, T. (2013) \emph{Strictly and non-strictly positive definite functions on spheres} \emph{Bernoulli}, \bold{19}(4), 1327-1349. } \author{Christoph Berreth, \martin} \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RMchoquet}}, \command{\link{spherical models}} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMmultiquad(delta=0.5, tau=1) plot(model, dim=2) ## the following two pictures are the same %nicht mehr als 0.12 da inversen der cov matrizen sich dann stark unterscheiden x <- seq(0, 0.12, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto") \dontshow{FinalizeExample()}}RandomFields/man/RFgetModel.Rd0000644000176200001440000000421613437301604015657 0ustar liggesusers\name{RFgetModel} \alias{RFgetModel} %\alias{GetModelInfo} %\alias{GetModel} %- Also NEED an '\alias' for EACH other topic documented here. \title{Internally stored model} \description{ The function returns the stored model. } \usage{ RFgetModel(register, explicite.natscale, show.call=FALSE, origin="original") } %- maybe also 'usage' for other objects documented here. \arguments{ \item{register}{\eqn{0,...,21} or an evaluating function, e.g. \command{\link{RFsimulate}}. Place where intermediate calculations are stored. See also section \code{Registers} in \command{\link{RFoptions}}. } \item{explicite.natscale}{logical. Advanced option. If missing, then the model is returned as stored. If \code{FALSE} then any \command{\link{RMnatsc}} is ignored. If \code{TRUE} then any \command{\link{RMnatsc}} is tried to be combined with leading \command{\link{RMS}}, or returned as such. } \item{show.call}{logical or character. If \code{FALSE} then the model is shown as interpreted. If \code{TRUE} then the user's input including the calling function is returned. See example below. If \code{show.call} is a character it behaves as \code{\link[=RFgetModelInfo]{which.submodels}}. } \item{origin}{\argOrigin} } \details{ Whereas \command{\link{RFgetModel}} returns a model that can be re-used by the user, \command{RFgetModelInfo} can return detailed information. } \note{ Put \code{Storing=TRUE}, see \command{\link{RFoptions}}, if you like to have (more) internal information in case of failure of an initialization of a random field simulation. } \value{ The stored model is returned in list format. } \me \seealso{\command{\link{RFgetModelInfo}}, \command{\link{RFsimulate}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4) RFgetModel(show.call=FALSE) RFgetModel(show.call=TRUE) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMintern.Rd0000644000176200001440000000452413437301604015427 0ustar liggesusers\name{RMintern} \alias{RMintern} % to do: check the list with the make_internal and internal=TRUE \alias{RMmixed} \alias{ROmissing} \alias{RMnull} \alias{RMSpower} \alias{RO#} \alias{RO>} \alias{RMselect} \alias{RMSpower} \alias{RMmult_inverse} \alias{RMsetparam} \alias{RMshape.ave} \alias{RMshape.stp} \alias{RMr3binner} \alias{RRarcsqrt} \alias{RRsetDistr} \alias{RMptsGivenShape} \alias{RMstandardShape} \alias{RMstatShape} \alias{RPS} \alias{RPplus} \alias{RPmult} \alias{RPmppplus} \alias{RPtrend} \title{Internal models} \description{ Internal models or model names that may appear in feedbacks from 'RandomFields'. Those endings by \sQuote{Intern} should appear only in very rare cases. } \details{ The following and many more internal models exist: \itemize{ \item RF__Name__ : internal representation of certain functions \link[=RF]{RF__name__} \item \code{RO#} : model for transforming coordinates within the cartesian system \item \code{RO>} : model for transforming earth coordinates to cartesian coordinates \item \code{ROmissing} : for error messages only \item \code{RMmixed} : internal representation of a \link[=formula]{mixed model} \item \code{RMselect} : will be obsolete in future \item \code{RMsetparam}, \code{RMptsGivenShape}, \code{RMstandardShape}, \code{RMstatShape} : for max-stable processes and Poisson processes: models that combine shape functions with corresponding point processes \item \code{RP__name__Intern} : internal representations of some \link[=RP]{processes} \item \code{RPS}, \code{RPplusp}, etc. : specific processes for \link{RMS} and \link{RMplus} etc. (For those covariance models that have specific simulation processes programmed.) \item \command{\link{RMS}} : internal representation of the modifying arguments \code{var}, \code{scale}, \code{Aniso}, \code{proj} } } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## in the following 'RPplus' appears as internal model x <- seq(0, 10, 1) z <- RFsimulate(RPspecific(RMexp() + RMnugget()), x) RFgetModelInfo(which="internal", level=0) \dontshow{FinalizeExample()}} RandomFields/man/RFsp-class.Rd0000644000176200001440000001363113437301604015645 0ustar liggesusers\name{RFsp-class} \docType{class} \alias{RFsp-class} \alias{RFspatialDataFrame} \alias{RFdataFrame} %% S4 methods \alias{summary,RFsp-method} \alias{variance,RFsp-method} \alias{dimensions,RFsp-method} \alias{dimensions,RFdataFrame-method} \alias{dimensions,RFspatialDataFrame-method} %\alias{isGridded} %\alias{isGridded,RFsp-method} \alias{RFspDataFrame2conventional} \alias{RFspDataFrame2conventional,RFsp-method} \alias{RFspDataFrame2dataArray} \alias{RFspDataFrame2dataArray,RFsp-method} \alias{[,RFsp-method} \alias{[,RFsp,ANY,ANY-method} \alias{[,RFsp,ANY,ANY,ANY-method} \alias{[<-,RFsp-method} \alias{[<-,RFsp,ANY,ANY-method} \alias{[<-,RFsp,ANY,ANY,ANY-method} \alias{RFspatialDataFrame-class} \alias{RFspatialDataFrame} \alias{RFdataFrame-class} \alias{RFdataFrame} \title{Class \code{RFsp}} \description{ \code{"RFsp"} is a virtual class which contains the four classes \command{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}} (data on a full grid and \eqn{space-time-dimension \ge 2}{space-time-dimension > 2}), \command{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}} (data not on a grid and \eqn{space-time-dimension \ge 2}{space-time-dimension > 2}), \command{\link[=RFgridDataFrame-class]{RFgridDataFrame}} (data on a full grid and \eqn{space-time-dimension = 1}), \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}} (data not on a grid and \eqn{space-time-dimension = 1}) The first two subclasses are summarized in \code{"RFspatialDataFrame"} whilst the latter two are summarized in \code{"RFdataFrame"}. % The first two classes are summarized in the class % \code{RFspatialDataFrame} the last two classes in the class %\code{ RFdataFrame}. } \section{Objects from the Class}{ are never to be generated; only derived classes can be meaningful. } %\section{Slots}{ % \describe{ % only for sub-classes % \command{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFram%e}} % and \command{\link[=RFspatialPointsDataFrame-class]{RFspatialPoints%DataFrame}}: % \item{\code{bbox}:}{Object of class \code{"matrix"}; 2-column matrix % holding the minimum in first and maximum in second column for the % x-coordinate (first row), y-coordinate (second row) and optionally, % for points and grids only, further coordinates. The constructed % Spatial object will be invalid if any bbox values are NA or % infinite. The column names must be \code{c("min", "max")}} % \item{\code{proj4string}:}{Object of class \code{"CRS"}; % holding a valid proj4 string, which can be used for unprojecting % or reprojecting coordinates; it is initialised to NA. Other strings % are checked for validity in the rgdal package, but attempts to % assign a string containing \dQuote{longlat} to data extending beyond % longitude [-180, 360] or lattitude [-90, 90] will be stopped. } % } %} \section{Methods}{ \describe{ % \item{bbox}{\code{signature(obj = "Spatial")}: retrieves the bbox element } \item{summary}{\code{signature(obj = "RFsp")}: returns a summary of the object; uses or imitates summary method of class \code{\link[sp:Spatial-class]{Spatial}} from the \pkg{sp}-package} \item{dimensions}{\code{signature(obj = "RFsp")}: retrieves the number of spatial or spatio-temporal dimensions spanned } %\item{isGridded}{\code{signature(obj = "RFsp")}: logical, tells whether % the data is on a regular spatial grid } \item{RFspDataFrame2dataArray}{\code{signature(obj = "RFsp")}: transforms \code{RFsp} objects to array } \item{RFspDataFrame2conventional}{\code{signature(obj = "RFsp")}: transforms \code{RFsp} objects to a list with additional information } \item{[}{\code{signature(obj = "RFsp")}: selects columns of the \code{data}-slot, while all other slots are kept unmodified} \item{[<-}{\code{signature(obj = "RFsp")}: replaces columns of the \code{data}-slot, while all other slots are kept unmodified} % \item{plot}{\code{signature(x = "Spatial", y = "missing")}: plot method % for spatial objects; does nothing but setting up a plotting region choosing % a suitable aspect if not given(see below), colouring the plot background using either a bg= argument or par("bg"), and possibly drawing axes. } \item{variance}{\code{signature(object = "RFsp")}: returns the kriging variance if available} } } %\usage{ %Spatial(bbox, proj4string = CRS(as.character(NA))) %} %\arguments{ %\item{bbox}{a bounding box matrix} %\item{proj4string}{a CRS object} %} \author{Alexander Malinowski; \martin} \section{Warning }{This class is not useful itself, but the above mentioned classes in this package derived from it. } \seealso{ \command{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}}, \command{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}}, \command{\link[=RFgridDataFrame-class]{RFgridDataFrame}}, \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}}, \command{\link{sp2RF}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Generating an object of class "RFspatialGridDataFrame" ## and one of class "RFspatialPointsDataFrame". model <- RMcauchy(gamma=4, var=0.1, scale=2) x <- seq(0,10,len=100) r <- cbind(runif(100, min=1, max=9),runif(100, min=1, max=9)) z1 <- RFsimulate(model=model, x=x, y=x, n=4) z2 <- RFsimulate(model=model, x=r, n=2) ## Applying available functions. class(z1) class(z2) summary(z1) summary(z2) plot(z1) plot(z2) %isGridded(z1) ## TRUE %isGridded(z2) ## FALSE z4 <- RFspDataFrame2conventional(z2) str(z2) str(z4) dta <- data.frame(coords=z4$x,data=z2@data[,1]) z3<-RFinterpolate(model=model, x=x, y=x, data=dta) plot(z3,z2) ## Illustrating the warning. a1 <- new("RFpointsDataFrame") str(a1) try(a2 <- new("RFsp")) ## ERROR \dontshow{FinalizeExample()}} \keyword{classes} RandomFields/man/RMmodelExt-class.Rd0000644000176200001440000000734413437301604017017 0ustar liggesusers\name{RMmodelFit-class} \docType{class} \alias{RMmodelFit-class} \alias{RM_modelFit-class} \alias{[,RMmodelFit-method} \alias{[,RMmodelFit,ANY,ANY-method} \alias{[,RMmodelFit,ANY,ANY,ANY-method} \alias{[<-,RMmodelFit-method} \alias{[<-,RMmodelFit,ANY,ANY-method} \alias{[<-,RMmodelFit,ANY,ANY,ANY-method} \alias{show,RMmodelFit-method} \alias{print,RMmodelFit-method} \alias{anova,RMmodelFit-method} \alias{summary,RMmodelFit-method} \alias{print.RMmodelFit} \alias{print.RM_modelFit} \alias{anova.RM_modelFit} \alias{summary.RM_modelFit} \title{Class CLASS_FIT } \description{ Extension of class \code{\link[=RMmodel-class]{RMmodel}} which additionally contains the likelihood of the data w.r.t. the covariance model represented by the CLASS_CLIST part, the estimated trend of the data if it is a constant trend, and the residuals of the data w.r.t. the model. Objects of this class only occur as slots in the output of "RFfit". } %\usage{ %anova.RM_modelFit(object, ...) %print.RM_modelFit(x, ...) %summary.RM_modelFit(object, ..., isna.param) %} %\arguments{ % \item{object, x, ...}{ % see the respective generic function % } % \item{isna.param}{ % logical. Weather the vector of parameters should be considered as % having \code{NA}s. In this case, not the parameters, but the % internally used variables are reported. % } % %} \section{Creating Objects}{ Objects are only meant to be created by the function \code{\link{RFfit}}. } \section{Slots}{ \describe{ \item{\code{model,formel}:}{See \code{\link[=RMmodel]{RMmodel}}.} \item{\code{variab}:}{ vector of estimated variables. Variables are used in the internal representation and can be a subset of the parameters. } \item{\code{param}:}{ vector of estimated parameters } \item{\code{covariate}:}{ to do } \item{\code{globalvariance}:}{ to do } \item{\code{hessian}:}{ to do } \item{\code{likelihood}:}{numeric; the likelihood of the data w.r.t. the covariance model} \item{\code{AIC}:}{the AIC value for the ml estimation} \item{\code{AICc}:}{the corrected AIC value for the ml estimation} \item{\code{BIC}:}{the BIC value for the ml estimation} \item{\code{residuals}:}{array or of class \code{\link[=RFsp-class]{RFsp}}; residuals of the data w.r.t. the trend model} % \item{\code{call}:}{See \code{\link[=RMmodel-class]{RMmodel}}.} % \item{\code{name}:}{See \code{\link[=RMmodel]{RMmodel}}.} % \item{\code{par.model}:}{See \code{\link[=RMmodel]{RMmodel}}.} % \item{\code{par.general}:}{See \code{\link[=RMmodel]{RMmodel}}.} % \item{\code{trend}:}{numeric; the estimated mean of the data (if a % constant mean was specified in the model)} } } \section{Extends}{ Class \code{CLASS_CLIST}, directly. } \section{Methods}{ \describe{ \item{[}{\code{signature(x = CLASS_FIT)}: enables accessing the slots via the \code{"["}-operator, e.g. \code{x["likelihood"]}} \item{[<-}{\code{signature(x = CLASS_FIT)}: enables replacing the slots via the \code{"["}-operator} \item{show}{\code{signature(x = "RFfit")}: returns the structure of \code{x}} \item{print}{\code{signature(x = "RFfit")}: identical with \command{show}-method} \item{anova}{performs a likelihood ratio test base on a chisq approximation } \item{summary}{gives a summary} } } %\section{Details}{ %} \author{Alexander Malinowski; \martin} \seealso{ \code{\link[=RMmodel-class]{RMmodel}}, \command{\link{RFfit}}. } \keyword{classes} \keyword{print} \keyword{hplot} \examples{\dontshow{StartExample()} # see RFfit \dontshow{FinalizeExample()}} RandomFields/man/RMbcw.Rd0000644000176200001440000000543113437301604014701 0ustar liggesusers\name{RMbcw} \alias{RMbcw} \title{Model bridging stationary and intrinsically stationary processes} \description{ \command{\link{RMbcw}} is a variogram model that bridges between some intrinsically stationary isotropic processes and some stationary ones. It reunifies the \command{\link{RMgenfbm}} \sQuote{b}, \command{\link{RMgencauchy}} \sQuote{c} and \command{\link{RMdewijsian}} \sQuote{w}. The corresponding centered semi-variogram only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{\gamma(r) = \frac{(r^{\alpha}+1)^{\beta/\alpha}-1}{2^{\beta/\alpha} -1}}{ \gamma(r)=[(r^{\alpha}+1)^{\beta/\alpha}-1] / (2^{\beta/\alpha}-1)} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2} and \eqn{\beta \le 2}{\beta <= 2}.\cr } \usage{ RMbcw(alpha, beta, c, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; should be in the interval (0,2].} \item{beta}{a numerical value; should be in the interval (-infty,2].} \item{c}{only for experts. If given, a not necessarily positive definite function \eqn{c-\gamma(r)} is built.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above variogram remains unmodified.} } \details{ For \eqn{\beta >0}, \eqn{\beta<0}, \eqn{\beta=0} we have the generalized fractal Brownian motion \command{\link{RMgenfbm}}, the generalized Cauchy model \command{\link{RMgencauchy}}, and the de Wisjian model \command{\link{RMdewijsian}}, respectively. Hence its two arguments \code{alpha} and \code{beta} allow for modelling the smoothness and a wide range of tail behaviour, respectively. } \value{ \command{\link{RMbcw}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}} } \references{ \itemize{ \item Schlather, M (2014) A parametric variogram model bridging between stationary and intrinsically stationary processes. \emph{arxiv} \bold{1412.1914}. % \item Martin's Toledo-Chapter: Construction of covariance functions % and unconditional simulation of random fields, Application to variograms } } \me \seealso{ \command{\link{RMlsfbm}} is equipped with Matheron's constant \eqn{c} for the fractional brownian motion, \command{\link{RMgenfbm}}, \command{\link{RMgencauchy}}, \command{\link{RMdewijsian}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbcw(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RRmcmc.Rd0000644000176200001440000000405313437301604015051 0ustar liggesusers\name{RRmcmc} \alias{RRmcmc} \title{Random Sample From The Modulus Of A Function} \description{ \command{RRmcmc} draws a random sample from the modulus of any given function (provided the integral is finite). } \usage{ RRmcmc(phi, mcmc_n, sigma, normed, maxdensity, rand.loc, gibbs) } \arguments{ \item{phi}{an arbitrary integrable function } \item{mcmc_n}{ positive integer. Every \code{mcmc_n}th element of the MCMC chain is returned. } \item{sigma}{positive real number. The MCMC update is done by adding a normal variable with standard deviation \code{sigma}. } \item{normed}{logical. Only used if the value of the density is calculated. If \code{FALSE} the unnormed value given by \code{phi} is returned. Default: \code{FALSE}. } \item{maxdensity}{positive real number. The given density is truncated at \code{maxdensity}. Default: 1000. } \item{rand.loc}{logical. Internal. Do not change the value. Default: \code{FALSE}. } \item{gibbs}{logical. If \code{TRUE} only one component is updated at a time. Default: \code{FALSE}. } } \value{ \command{\link{RRmcmc}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ The use of \command{RRmcmc} is completely on the risk of the user. There is no way to check whether the integral of the modulus is finite. } \me \seealso{ \command{\link{RMmodel}}, \link{RR}, \command{\link{RRdistr}}, \command{\link{RMuser}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter ## not exponential, but the Laplace distribution as symmetry is assumed z <- RFrdistr(RRmcmc(RMexp(), sigma=1), n=10000, cores=1) hist(z, 100, freq=FALSE) curve(0.5 * exp(-abs(x)), add=TRUE, col="blue") ## Laplace distribution \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMcurlfree.Rd0000644000176200001440000000442113437301604015733 0ustar liggesusers\name{RMcurlfree} \alias{RMcurlfree} \title{Curlfree Covariance Model} \description{ \command{\link{RMcurlfree}} is a multivariate covariance model which depends on a univariate stationary covariance model where the covariance function phi(h) is twice differentiable. The corresponding matrix-valued covariance function C of the model only depends on the difference \eqn{h}{h} between two points and it is given by the following components: \itemize{ \item the potential \item the vector field given by \deqn{ C(h)=( - \nabla_h (\nabla_h)^T ) C_0(h) } \item the field of sinks and sources } } \usage{ RMcurlfree(phi, which, var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary covariance model (2- or 3-dimensional).} \item{which}{vector of integers. If not given all components are returned; otherwise the selected components are returned. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model returns the potential field in the first component, the corresponding curlfree field and field of sources and sinks in the last component. See also the models \command{\link{RMdivfree}} and \command{\link{RMvector}}. } \value{ \command{\link{RMcurlfree}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. \emph{Stochastic Models} \bold{28:3}. } } \me \seealso{ \command{\link{RMderiv}}, \command{\link{RMdivfree}}, \command{\link{RMvector}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcurlfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated, select.variables=list(1, c(1, 2:3), 4)) \dontshow{FinalizeExample()}}RandomFields/man/RandomFields.Rd0000644000176200001440000002763713437301604016252 0ustar liggesusers\name{RandomFields-package} \alias{RandomFields} \alias{RandomFields-package} \docType{package} \title{Simulation and Analysis of Random Fields} \description{ The package \code{RandomFields} offers various tools for \enumerate{ \item{\bold{model estimation (ML) and inference (tests)}} for regionalized variables and data analysis, \item{\bold{simulation}} of different kinds of random fields, including \itemize{ \item multivariate, spatial, spatio-temporal, and non-stationary Gaussian random fields, \item Poisson fields, binary fields, Chi2 fields, t fields and \item max-stable fields. } It can also deal with non-stationarity and anisotropy of these processes and conditional simulation (for Gaussian random fields, currently). % \item{\bold{model estimation}} for (geostatistical) linear (mixed) models } See \url{http://ms.math.uni-mannheim.de/de/publications/software/} for \bold{intermediate updates}. } \details{ The following features are provided by the package: \enumerate{ \item \bold{Bayesian Modelling} \itemize{ \item See \link{Bayesian Modelling} for an introduction to hierarchical modelling. } \item \bold{Coordinate systems} \itemize{ \item Cartesian, earth and spherical coordinates are recognized, see \link{coordinate systems} for details. \item A list of valid models is given by \link{spherical models}. } \item \bold{Data and example studies}: Some data sets and published code are provided to illustrate the syntax and structure of the package functions. \itemize{ \item \code{\link{soil}} : soil physical data \item \code{\link{weather}} : UWME weather data \item \code{\link{papers}} : code used in the papers published by the author(s) } \item \bold{Estimation of parameters (for second-order random fields)} \itemize{ \item \command{\link{RFfit}} : general function for estimating parameters; (for Gaussian random fields) \item \command{\link{RFhurst}} : estimation of the Hurst parameter \item \command{\link{RFfractaldim}} : estimation of the fractal dimension \item \command{\link{RFvariogram}} : calculates the empirical variogram \item \command{\link{RFcov}} : calculates the empirical (auto-)covariance function } \item \bold{Graphics} \itemize{ \item Fitting a covariance function manually \command{\link{RFgui}} \item the generic function \command{\link[graphics]{plot}} \item global graphical parameters with \command{\link{RFpar}} } \item \bold{Inference (for Gaussian random fields)} \itemize{ \item \command{\link{RFcrossvalidate}} : cross validation \item \command{\link{RFlikelihood}} : likelihood \item \command{\link{RFratiotest}} : likelihood ratio test \item \command{\link[=AIC.RF_fit]{AIC}}, \command{\link[=AICc.RF_fit]{AICc}}, \command{\link[=BIC.RF_fit]{BIC}}, \command{\link[=anova.RF_fit]{anova}}, \command{\link[=logLik.RFfit]{logLik}} } \item \bold{Models} \itemize{ \item For an introduction and general properties, see \link{RMmodels}. \item For an overview over classes of covariance and variogram models --e.g. for \bold{geostatistical} purposes-- see \link{RM}. More sophisticated models and covariance function operators are included. % \item To apply the offered package procedures to \bold{mixed models} % -- e.g. appearing in genetical data analysis-- see \item \command{\link{RFformula}} reports a new style of passing a model since version 3.3. \item definite models are evaluated by \command{\link{RFcov}}, \command{\link{RFvariogram}} and \command{\link{RFcovmatrix}}. For a quick impression use \code{\link{plot}(model)}. \item non-definite models are evaluated by \command{\link{RFfctn}} and \command{\link{RFcalc}} \item \command{\link{RFlinearpart}} returns the linear part of a model \item \command{\link{RFboxcox}} deals explicitly with Box-Cox transformations. In many cases it is performed implicitly. } \item \bold{Prediction (for second-order random fields)} \itemize{ \item \command{\link{RFinterpolate}} : kriging, including imputing } \item \bold{Simulation} \itemize{ \item \command{\link{RFsimulate}}: Simulation of random fields, including conditional simulation. For a list of all covariance functions and variogram models see \command{\link{RM}}. Use \command{\link{plot}} for visualisation of the result. } \item \bold{S3 and S4 objects} \itemize{ \item The functions return S4 objects based on the package \pkg{sp}, if \code{\link[=RFoptions]{spConform=TRUE}}. This is the default. If \code{\link[=RFoptions]{spConform=FALSE}}, simple objects as in version 2 are returned. These simple objects are frequently provided with an S3 class. This option makes the returning procedure much faster, but currently does not allow for the comfortable use of \command{\link[=plot-method]{plot}}. \item \command{\link[graphics]{plot}}, \command{\link[base]{print}}, \command{\link[base]{summary}}, sometimes also \command{\link[utils]{str}} recognise these S3 and S4 objects \item use \command{\link{sp2RF}} for an explicit transformation of \pkg{sp} objects to S4 objects of \pkg{RandomFields}. \item Further generic functions are available for fitted models, see \sQuote{Inference} above. % \item \bold{Note} that, in many cases, \command{print} will return % an invisible list. This list contains the main information of the % S4 object in an accessible way and is in many cases the % information obtained from \code{summary}. See examples below. } \item \bold{Xtended} features, especially for package programmers \itemize{ \item might decide on a large variety of arguments of the simulation and estimation procedures using the function \command{\link{RFoptions}} \item may use \sQuote{./configure --with-tcl-config=/usr/lib/tcl8.5/tclConfig.sh --with-tk-config=/usr/lib/tk8.5/tkConfig.sh} to configure R } } } \section{Changings}{ A list of major changings from Version 2 to Version 3 can be found in \link{MajorRevisions}. \link{Changings} lists some further changings, in particular of argument and argument names. \pkg{RandomFields} should be rather stable when running it with \pkg{parallel}. However \pkg{RandomFields} might crash severely if an error occurs when running in parallel. When used with \pkg{parallel}, you might set \code{RFoptions(cores = 1)}. Note that \code{RFoptions(cores = ...)} with more than 1 core uses another level of parallelism which will be in competetions with \pkg{parallel} during runtime. } % In the beta version, the following functionalities are currently % not available: % \itemize{ % \item \command{\link{ShowModels}} % \item numerical evaluation of the covariance function in tbm2 % \item Harvard Rue's Markov fields % } \seealso{ See also \link{RF}, \link{RM}, \link{RP}, \link{RR}, \link{RC}, \link{R.} } \note{ The following packages enable further choices for the optimizer (instead of \command{optim}) in RandomFields: \pkg{optimx}, \pkg{soma}, \pkg{GenSA}, \pkg{minqa}, \pkg{pso}, \pkg{DEoptim}, \pkg{nloptr}, \pkg{RColorBrewer}, \pkg{colorspace} } \section{Update}{ Current updates are available through \url{http://ms.math.uni-mannheim.de/de/publications/software}. } \me \references{ \itemize{ \item Singleton, R.C. (1979). In \emph{Programs for Digital Signal Processing} Ed.: Digital Signal Processing Committee and IEEE Acoustics, Speech, and Signal Processing Committe (1979) IEEE press. \item Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/} \item see also the corresponding \href{../doc/multivariate_jss.pdf}{vignette}. } } \section{Contributions}{ \itemize{ \item Contributions to version 3.0 and following:\cr Felix Ballani (TU Bergakademie Freiberg; Poisson Polygons, 2014) \cr Daphne Boecker (Univ. Goettingen; RFgui, 2011)\cr Katharina Burmeister (Univ. Goettingen; testing, 2012)\cr Sebastian Engelke (Univ. Goettingen; RFvariogram, 2011-12)\cr Sebastian Gross (Univ. Goettingen; tilde formulae, 2011)\cr Alexander Malinowski (Univ. Mannheim; S3, S4 classes 2011-13)\cr Juliane Manitz (Univ. Goettingen; testing, 2012)\cr Johannes Martini (Univ. Goettingen; RFvariogram, 2011-12)\cr Ulrike Ober (Univ. Goettingen; help pages, testing, 2011-12)\cr Marco Oesting (Univ. Mannheim; Brown-Resnick processes, Kriging, Trend, 2011-13)\cr Paulo Ribeiro (Unversidade Federal do Parana; code adopted from \pkg{geoR}, 2014)\cr Kirstin Strokorb (Univ. Mannheim; help pages, 2011-13)\cr \item Contributions to version 2.0 and following:\cr Peter Menck (Univ. Goettingen; multivariate circulant embedding)\cr R Core Team, Richard Singleton (fft.c and advice) \item Contributions to version 1 and following:\cr Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA making available an algorithm for AVL trees (avltr*) } } \section{Thanks}{ Patrick Brown : comments on Version 3\cr Paulo Ribeiro : comments on Version 1\cr Martin Maechler : advice for Version 1 } \section{Financial support}{ \itemize{ \item V3.0 has been financially supported by the German Science Foundation (DFG) through the Research Training Group 1953 \sQuote{Statistical Modeling of Complex Systems and Processes --- Advanced Nonparametric Approaches} (2013-2018). \item V3.0 has been financially supported by Volkswagen Stiftung within the project \sQuote{WEX-MOP} (2011-2014). \item Alpha versions for V3.0 have been financially supported by the German Science Foundation (DFG) through the Research Training Groups 1644 \sQuote{Scaling problems in Statistics} and 1023 \sQuote{Identification in Mathematical Models} (2008-13). \item V1.0 has been financially supported by the German Federal Ministry of Research and Technology (BMFT) grant PT BEO 51-0339476C during 2000-03. \item V1.0 has been financially supported by the EU TMR network ERB-FMRX-CT96-0095 on ``Computational and statistical methods for the analysis of spatial data'' in 1999. } } \keyword{spatial} \examples{\dontshow{StartExample(reduced=FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulate some data first (Gaussian random field with exponential # covariance; 6 realisations) model <- RMexp() x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=6) ## select some data from the simulated data xy <- coordinates(z) pts <- sample(nrow(xy), min(100, nrow(xy) / 2)) dta <- matrix(nrow=nrow(xy), as.vector(z))[pts, ] dta <- cbind(xy[pts, ], dta) plot(z, dta) ## re-estimate the parameter (true values are 1) estmodel <- RMexp(var=NA, scale=NA) (fit <- RFfit(estmodel, data=dta)) ## show a kriged field based on the estimated parameters kriged <- RFinterpolate(fit, x, x, data=dta) plot(kriged, dta) \dontshow{FinalizeExample()}} RandomFields/man/RPspecific.Rd0000644000176200001440000000705213437301604015717 0ustar liggesusers\name{Specific} \alias{Specific} \alias{RPspecific} \title{Methods that are specific to certain covariance models} \description{ This model determines that the (Gaussian) random field should be modelled by a particular method that is specific to the given covariance model. } \usage{ RPspecific(phi, boxcox) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } % \item{loggauss}{optional arguments; same meaning as for % \command{\link{RPgauss}}.} } \details{ \code{RPspecific} is used for specific algorithms or specific features for simulating certain covariance functions. \itemize{ % i.W. alle Modele mit struct und do Funktion \item{\command{\link{RMplus}}}{ is able to simulate separately the fields given by its summands. This is necessary, e.g., when a trend model \command{\link{RMtrend}} is involved. } \item{\command{\link{RMmult}}} { for Gaussian random fields only. \command{RMmult} simulates the random fields of all the components and multiplies them. This is repeated several times and averaged. } \item{\command{\link{RMS}}}{ Then, for instance, \code{sqrt(var)} is multiplied onto the (Gaussian) random field after the field has been simulated. Hence, when \code{var} is random, then for each realization of the Gaussian field (for \code{n>1} in \command{\link{RFsimulate}}) a new realization of \code{var} is used. Further, new coordinates are created where the old coordinates have been divided by the \code{scale} and/or multiplied with the \code{Aniso} matrix or a \code{proj}ection has been performed. \code{\link{RPspecific}(\link{RMS}())} is called internally when the user wants to simulate \code{Aniso}tropic fields with isotropic methods, e.g. \command{\link{RPtbm}}. } \item{\command{\link{RMmppplus}}}{ } \item{\command{\link{RMtrend}}}{ } % \item{\command{\link{RM}}}{} } Note that \code{RPspecific} applies only to the first model or operator in the argument \code{phi}. } \value{ \command{RPspecific} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. } } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## example for implicit use model <- RMgauss(var=10, s=10) + RMnugget(var=0.1) plot(model) plot(RFsimulate(model=model, 0:10, 0:10, n=4)) ## The following function shows the internal structure of the model. ## In particular, it can be seen that RPspecific is applied to RMplus. RFgetModelInfo(level=0, which="internal") ## example for explicit use: every simulation has a different variance model <- RPspecific(RMS(var=unif(min=0, max=100), RMgauss())) x <- seq(0,50,0.02) plot(RFsimulate(model, x=x, n=4), ylim=c(-15,15)) \dontshow{FinalizeExample()}} \seealso{ \link{Gaussian}, \link{RP}. } \keyword{methods} RandomFields/man/RMlsfbm.Rd0000644000176200001440000000335713437301604015236 0ustar liggesusers\name{RMlsfbm} \alias{RMlsfbm} \title{Locally Positive Definite Function Given by the Fractal Brownian Motion} \description{ \command{\link{RMlsfbm}} is a positive definite function on the unit ball in \eqn{R^d} centred at the origin, \deqn{C(r) = c - r^\alpha}{C(r) = c - r^\alpha} with \eqn{r = \|x- y\|\in [0,1]}{0 <= r = || x - y || <= 1}. } \usage{ RMlsfbm(alpha, const, var, scale, Aniso, proj) } \arguments{ \item{alpha}{numeric in \eqn{(0,2)}; refers to the fractal dimension of the process.} \item{const}{the \code{const}ant \eqn{c} is given by the formula \deqn{ c = 2^{-\alpha} \Gamma(d / 2 + \alpha/2) \Gamma(1 - \alpha/2) / \Gamma(d / 2) } and should not be changed by the user in order to ensure positive definiteness. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMlsfbm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Martini, J., Schlather, M., Simianer, H. (In preparation.) } } \me \seealso{ \command{\link{RMbcw}} generalizes \command{RMlsfbm} in case that \eqn{c} is given, \command{\link{RMfbm}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlsfbm(alpha=1, scale=10) x <- seq(0, 10, 0.02) plot(model, xlim=c(0,10)) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMid.Rd0000644000176200001440000000177413437301604014530 0ustar liggesusers\name{RMid} \alias{RMid} \title{Identical Model} \description{ \command{RMid} is the identical function \eqn{f(x) = x} where \eqn{x} is a vector of coordinates and \eqn{f(x)} is a model value. } \usage{ RMid()%var, scale, Aniso, proj) } %\arguments{ % \item{var,scale,Aniso,proj}{optional arguments; same meaning for any % \command{\link{RMmodel}}. If not passed, the above % covariance function remains unmodified.} %} \value{ \command{\link{RMid}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}. \command{RMid}, \command{RMtrafo}, \command{RMprod} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## C(x,y) = < x, y > RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RFpar.Rd0000644000176200001440000000161213437301604014676 0ustar liggesusers\name{RFpar} \alias{RFpar} \title{Graphical parameters for plots} \description{ This function sets globally graphical parameters for plots of \code{RMmodels}, simulations and estimations. } \usage{ RFpar(...) } \arguments{ \item{...}{see \command{\link[graphics]{par}} } } \value{ If \command{RFpar} is called without arguments, the current list is returned. If \command{RFpar} is called with \code{NULL} only, the current list is deleted. Otherwise the arguments are stored for global use in RandomFields. } \me \seealso{ \link{plot-method} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFpar(col="red") plot(RMexp()) \dontshow{FinalizeExample(); RFpar(col=NULL)}} \keyword{spatial} \keyword{models} RandomFields/man/RFsimulate.more.examples.Rd0000644000176200001440000002144013437301604020516 0ustar liggesusers\name{RFsimulate.more.examples} \alias{RFsimulate.more.examples} \title{Further Examples for the Simulation of Random Fields} \description{ This man page will give a collection of basic examples for the use of \code{\link{RFsimulate}}. For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see \link{RFsimulateAdvanced}. See \link{RFsimulate.sophisticated.examples} for further examples. } \seealso{ \command{\link{RFsimulate}}, \command{\link{RFsimulateAdvanced}}, \command{\link{RFsimulate.sophisticated.examples}}. } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ ############################################################# ## ## ## Basic examples: Unconditional simulation ## ## ## ############################################################# ############################################################# ## Example 1: Location formats / Plot method ## ############################################################# RFgetModelNames(type="variogram") ## the complete list covariance models ## and variogram models ## our choice is RMstable ## define the model: model <- RMtrend(mean=0.5) + # mean RMstable(alpha=1, var=4, scale=10) + # see help("RMstable") # for additional arguments RMnugget(var=1) # nugget ## define the locations: from <- 0 to <- 20 step <- 1 ## nicer, but also time consuming if step <- 0.1 x.seq <- seq(from, to, step) y.seq <- seq(from, to, step) ## simulate and get image of output: simulated <- RFsimulate(model, x=x.seq, y=y.seq) plot(simulated) ## for comparison only: image(x.seq, y.seq, RFspDataFrame2conventional(simulated)$data) ############################################################# ## ... using seq(from, by, length.out) notation len <- 21 ## more generally len <- (to-from)/step+1 x.short <- y.short <- c(from, step, len) short.matrix <- cbind(x.short, y.short) simulated <- RFsimulate(model = model, x=short.matrix) plot(simulated) ############################################################# ## ... using GridTopology for the locations: len <- 21 ## more generally len <- (to-from)/step+1 gridtop <- GridTopology(c(from,from), c(step,step), c(len,len)) simulated <- RFsimulate(model = model, x=gridtop) plot(simulated) ############################################################ ## arbitrary points x <- runif(100, max=20) y <- runif(100, max=20) # 100 points in 2 dimensional space simulated <- RFsimulate(model = model, x=x, y=y) plot(simulated) ############################################################# ## using the 1-dimensional plot routine ## simulate 1-dimensional random field first x.seq <- seq(from, to, step) # grid simulated <- RFsimulate(model = model, x=x.seq) plot(simulated) ############################################################# ## Example 2: Simulation several realizations at once ## ## Access to simulated data ## ############################################################# model <- RMstable(alpha=1.5) step <- 1 ## nicer, but also time consuming if step <- 0.1 x.seq <- seq(0, 20, step) y.seq <- seq(0, 20, step) # grid simulated <- RFsimulate(model, x=x.seq, y=y.seq, n=4) # 4 realizations at once plot(simulated) summary(simulated@data$variable1.n2) # summary of simulated univariate data of 2nd realization ############################################################# ## Example 3: simulating with trend ## ############################################################# ##s function model <- RMexp(var=0.3) + RMtrend(arbitraryfct = function(x,y) 2*sin(x)*cos(y)) x.seq <- y.seq <- seq(-5,5,0.1) simulated <- RFsimulate(model, x=x.seq,y=y.seq) plot(simulated) ############################################################# ## with linear trend surface: 3x-y model1 <- RMexp() + RMtrend(plane=c(3,-1), fctcoeff=1) # or equivalently: model2 <- RMexp() + RMtrend(arbitraryfct=function(x,y) 3*x-y) simulated <- RFsimulate(model1, x=x.seq, y=y.seq) persp(x.seq,y.seq, RFspDataFrame2conventional(simulated)$data, phi=30, theta=-3) ############################################################# ## Example 4: Brownian motion (using Stein's method) ## ############################################################# # Brownian motion (1 dimensional) alpha <- 1 # in [0,2) x.seq <- seq(0, 10, 0.001) simulated <- RFsimulate(model = RMfbm(alpha=alpha), x=x.seq) plot(simulated) ############################################################# ## Example 5: Models that depend on "submodels"; ## ## Combining models / Operators on models ## ############################################################# RFgetModelNames(operator=TRUE) ## list all models ## that are an operator; ## our choice is RMcoxisham D <- as.matrix(1) # a 1x1-correlation matrix for RMcoxisham submodel <- RMwhittle(nu=0.3) # submodel on which the operator ## model RMcoxisham will be applied model <- RMcoxisham(submodel, mu=0, D=D, beta=2) x.seq <- y.seq <- seq(-10,10,0.1) simulated <- RFsimulate(model = model, x=x.seq, y=y.seq) plot(simulated) ############################################################# ## further nesting of models is possible: #model2 <- RMcoxisham(RMintexp(RMdewijsian(alpha=1)), # mu=0, D=D, beta=2) #simulated <- RFsimulate(model = model2, # x=x.seq, y=y.seq) #plot(simulated) ############################################################# ## addition of random fields using RMplus model1 <- RMexp(var=5) + RMwhittle(nu=1, var=5) ## Alternatively, the common variance argument var=5 ## can be included in the RMplus model: model2 <- RMplus(C0 = RMexp(), C1 = RMwhittle(nu=1), var=5) x.seq <- y.seq <- seq(-10,10,0.5) simulated1 <- RFsimulate(model = model1, x=x.seq, y=y.seq) simulated2 <- RFsimulate(model = model2, x=x.seq, y=y.seq) # compare (should give the same plot(simulated1) plot(simulated2) sum(abs(simulated1@data - simulated2@data)) # should be numerically zero ############################################################# ## Example 6: A bivariate random field ## ############################################################# RFgetModelNames(vdim=2) ## list all bivariate models ## our choice is RMbiWM model <- RMbiwm(nudiag=c(1.3, 0.7), nured=2.5, s=c(1, 1, 1), cdiag=c(0.7, 0.8), rhored=1) x.seq <- y.seq <- seq(-10,10,0.5) simulated <- RFsimulate(model = model, x=x.seq, y=y.seq) plot(simulated) ############################################################# ## ## ## Basic examples: Conditional simulation ## ## ## ############################################################# ############################################################# ## Example 7: ways to pass given data ## ############################################################# # simulate given locations and corresponding data # (simulate measurements) x <- runif(n=100, min=-1, max=1) y <- runif(n=100, min=-1, max=1) dta <- RFsimulate(model = RMexp(), x=x, y=y, grid=FALSE) # locations for conditional simulation x.seq.cond <- y.seq.cond <- seq(-1.5,1.5,length=100) ############################################################# ## pass given data and locations as SP4-object ## given.data is an SP4-object cond.simulated <- RFsimulate(RMexp(), x=x.seq.cond, y=y.seq.cond, data=dta) ############################################################# ## or equivalently: pass given data and locations as a matrix cond.simulated.2 <- RFsimulate(RMexp(), x=x.seq.cond, y=y.seq.cond, data = cbind(x, y, dta@data)) all.equal(cond.simulated, cond.simulated.2) ## TRUE plot(cond.simulated, dta) ############################################################# ## multiple realizations # simulate corresponding data twice (2 measurements) given.data.2realize <- RFsimulate(model = RMwhittle(nu=1.1), x=x.seq.cond, y=y.seq.cond, data=dta, n=2) plot(given.data.2realize, dta) ############################################################# ## simulation not on a grid x.cond <- runif(1000, -2, 2) y.cond <- runif(1000, -2, 2) cond.simulated <- RFsimulate(model=RMwhittle(nu=1.4), x=x.cond, y=y.cond, grid=FALSE, data=dta) plot(cond.simulated, dta) ############################################################# ## Example 8: allow measurement errors ## ############################################################# # err.model specifies the error model, typically RMnugget cond.simulated <- RFsimulate(model=RMexp(), x=x.seq.cond, y=y.seq.cond, data=dta, err.model=RMnugget(var=1)) plot(cond.simulated, dta) }} \dontshow{FinalizeExample()}}RandomFields/man/RMexponential.Rd0000644000176200001440000000530213437301604016451 0ustar liggesusers\name{RMexponential} \alias{RMexponential} \alias{RMexponential} \title{Exponential operator} \description{ \command{\link{RMexponential}} yields a covariance model from a given variogram or covariance model. The covariance \eqn{C} is given as \deqn{ C(h) = \frac{\exp(\phi(h)) -\sum_{k=0}^n \phi^k(h)/k!}{\exp(\phi(0)) -\sum_{k=0}^n \phi^k(0)/k!}}{ C(h) = (\exp(\phi(h)) -\sum_{k=0}^n \phi^k(h)/k!) / (\exp(\phi(0)) -\sum_{k=0}^n \phi^k(0)/k!)} if \eqn{\phi} is a covariance model, and as \deqn{ C(h) = \exp(-\phi(h))} if \eqn{\phi} is a variogram model. } \usage{ RMexponential(phi, n, standardised, var, scale, Aniso, proj) } \arguments{ \item{phi}{a valid \command{\link{RMmodel}}; either a variogram model or a covariance model} \item{n}{integer, see formula above. Default is -1; if the multivariate dimension of the submodel is greater than 1 then only the default value is valid.} \item{standardised}{logical. If \code{TRUE} then the above formula holds. If \code{FALSE} then only the nominator of the above formula is returned. Default value is \code{TRUE}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ If \eqn{\gamma} is a variogram, then \eqn{\exp(-\gamma)} is a valid covariance. } \value{ \command{\link{RMexponential}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ See, for instance, \itemize{ \item Berg, C., Christensen, J. P. R., Ressel, P. (1984) Harmonic Analysis on Semigroups. \emph{Theory of Positive Definite and Related Functions.} Springer, New York. \item Sasvari, Z. (2013) \emph{Multivariate Characteristic and Correlation Functions}. de Gruyter, Berlin. \item Schlather, M. (2010) \emph{Some covariance models based on normal scale mixtures}, \emph{Bernoulli} \bold{16}, 780-797. \item Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J. M., Schlather, M. \emph{Advances and Challenges in Space-time Modelling of Natural Events}, Springer, New York. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexponential(RMfbm(alpha=1)) ## identical to RMexp() plot(RMexp(), model=model, type=c("p", "l"), pch=20) \dontshow{FinalizeExample()}}RandomFields/man/papers.SS11.Rd0000644000176200001440000000671313437301604015653 0ustar liggesusers\name{SS12} \alias{SS12} %\alias{Papers} %\alias{schlather} %\alias{Schlather} \title{Covariance Models for Random Vector Fields} \description{ Here, the code of the paper on \sQuote{Covariance Models for Random Vector Fields} is given. } \me \references{ \itemize{ \item Scheuerer, M. and Schlather, M. (2012) Covariance Models for Random Vector Fields. \emph{Stochastic Models}, \bold{82}, 433-451. } % Schlather, M. (2001) Simulation of stationary and isotropic random % fields. \emph{R-News} \bold{1} (2), 18-20. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ my.legend <- function(lu.x, lu.y, zlim, col, cex=1) { ## uses already the legend code of R-1.3.0 cn <- length(col) filler <- vector("character", length=(cn-3)/2) legend(lu.x, lu.y, y.i=0.03, x.i=0.1, legend=c(format(zlim[2], dig=2), filler, format(mean(zlim), dig=2), filler, format(zlim[1], dig=2)), lty=1, col=rev(col),cex=cex) } my.arrows <- function(xy, z, r, thinning) { startx <- as.vector(xy[,1] - r/2*z[as.integer(dim(z)[1]/3) + 1,,]) starty <- as.vector(xy[,2] - r/2*z[as.integer(dim(z)[1]/3) + 2,,]) endx <- as.vector(xy[,1] + r/2*z[as.integer(dim(z)[1]/3) + 1,,]) endy <- as.vector(xy[,2] + r/2*z[as.integer(dim(z)[1]/3) + 2,,]) startx[c(rep(TRUE, thinning), FALSE)] <- NA starty[c(rep(TRUE, thinning), FALSE)] <- NA endx[c(rep(TRUE, thinning), FALSE)] <- NA endy[c(rep(TRUE, thinning), FALSE)] <- NA arrows(x0=startx, y0=starty, x1=endx, y1=endy, length=0.03) } x <- c(-3, 3, 0.049) nu <- 3 col <- grey(seq(0, 1, 0.01)) thinning <- 21 length.arrow <- 1.5 / thinning runif(1) seed <- .Random.seed eps <- FALSE # true falls eps/pdf drucken \dontshow{if(RFoptions()$internal$examples_red){warning("modified "); x <- c(-3, 3, 0.5)}} for (modelname in c("divfree", "curlfree")) { cat(modelname, "\n") model <- list(modelname, list("matern", nu=nu)) xx <- seq(x[1], x[2], x[3]) RFoptions(print=2) if (!eps) { cf <- RFcov(model=model, x=cbind(xx, 0)) do.call(getOption("device"), list(height=5, width=5)) j <- 3 plot(xx, cf[(j-1) * length(xx) + (1 : length(xx)), j]) } .Random.seed <- seed z <- RFsimulate(x, x, model=model, n=1, CE.trial=2, Stor=TRUE, me="ci", print=3, CE.force=!TRUE) ## z[1,,] : Potentialfeld ## z[2:3,,] : vectorfeld ## z[4,,] : div bzw. rot if (eps) { ScreenDevice(height=5, width=5) } else { ScreenDevice(height=5, width=10) par(mfcol=c(1,2)) } par(mar=c(2.2,2.5,0.5,0.5), cex.axis=2, bg="white") for (no.vectors in c(TRUE,FALSE)) for (i in c(1,2,4)) { ## image i=1: Potential feld + Vektorfeld ## image i=4: div/rot feld + Vektorfeld if (i==1 || i==4) { image(xx, xx, col=col, z[i,,] ) if (no.vectors) my.legend(max(xx) - 0.3 * diff(range(xx)), min(xx) + 0.3 * diff(range(xx)), zlim=range(z[i,,]), col=col, cex=1.5) } else plot(Inf, Inf, xlim=range(xx), ylim=range(xx)) if (!no.vectors || i!=1 && i!=4) { xy <- as.matrix(expand.grid(xx, xx)) my.arrows(xy, z, length.arrow, thinning) } if (all(par()$mfcol==1)) { name <- paste(modelname, "_", nu, "_", !no.vectors, "_", i, sep="") cat(name,"\n") dev.copy2eps(file=paste(name, ".eps", sep="")) dev.copy2pdf(file=paste(name, ".pdf", sep="")) } } } par(mfcol=c(1,1)) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMma.Rd0000644000176200001440000000307313437301604014523 0ustar liggesusers\name{RMma} \alias{RMma} \title{Ma operator} \description{ \command{\link{RMma}} is a univariate stationary covariance model depending on a univariate stationary covariance model. The corresponding covariance function only depends on the difference \eqn{h}{h} between two points and is given by \deqn{C(h) = (\theta / (1 - (1-\theta) \phi(h)))^\alpha}{C(h) = (\theta / (1 - (1-\theta) * \phi(h)))^\alpha} } \usage{ RMma(phi, alpha, theta, var, scale, Aniso, proj) } \arguments{ \item{phi}{a stationary covariance \command{\link{RMmodel}}.} \item{alpha}{a numerical value; positive} \item{theta}{a numerical value; in the interval \eqn{(0,1)}{(0,1)}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } %\details{} \value{ \command{\link{RMma}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Ma, C. (2003) Spatio-temporal covariance functions generated by mixtures. \emph{Math. Geol.}, \bold{34}, 965-975. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMma(RMgauss(), alpha=4, theta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/conventional2RFspDataFrame.Rd0000644000176200001440000000403213437301604021004 0ustar liggesusers\name{conventional2RFspDataFrame} \alias{conventional2RFspDataFrame} \title{Coercion to class 'RFsp' objects} \description{ Generate an object of class \code{\link[=RFsp-class]{RFsp}} from conventional objects. } \usage{ conventional2RFspDataFrame(data, coords=NULL, gridTopology=NULL, n=1, vdim=1, T=NULL, vdim_close_together) } \arguments{ \item{data}{array; of dimension \code{c(vdim, space-time-dim, n)}; contains the values of the random field} \item{coords}{matrix of coordinates} \item{gridTopology}{3-row-matrix or of class \code{\link[sp:GridTopology-class]{GridTopology}}; specifies the grid vectors; either \code{coords} or \code{gridTopology} must be \code{NULL}} \item{n}{number of iid copies of the random field, default is 1} \item{vdim}{number of dimensions of the values of the random field, default is 1} \item{T}{time component if any. The length of the temporal grid is needed by \command{as.array} if the spatial locations are randomly scattered. } \item{vdim_close_together}{ logical. Currently, only \code{vdim_close_together=FALSE} is coded. In this case the dimensions of the data follow the order \dQuote{locations, multivariate, repeated}. Otherwise \dQuote{multivariate, locations, repeated}. } } %\details{} \value{Object of class \command{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}}, \command{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}}, \command{\link[=RFgridDataFrame-class]{RFgridDataFrame}} or \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}}. } \author{Alexander Malinowski, \martin} \examples{\dontshow{StartExample(reduced=50)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- 1:20 z <- RFsimulate(RMexp(), x, spConform=FALSE) z2 <- conventional2RFspDataFrame(z, coord=x) Print(z, z2) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RFsimulate.sophisticated.examples.Rd0000644000176200001440000002121613437301604022420 0ustar liggesusers\name{RFsimulate.sophisticated.examples} \alias{RFsimulate.sophisticated.examples} \title{Sophisticated Examples for the Simulation of Random Fields} \description{ This man page will give a collection of basic examples for the use of \code{\link{RFsimulate}}. For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see \link{RFsimulateAdvanced}. } \seealso{ \command{\link{RFsimulate}}, \command{\link{RFsimulateAdvanced}}. } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ ############################################################# ## ## ## Example 1: Gaussian field approximated by Poisson fields## ## ## ############################################################# for (mpp.intensity in c(1, 10, 100)){ # mpp.intensity of 1 is much too small but illustrates # how the "Coins" method works z <- RFsimulate(x=x, model=RPcoins(RMspheric()), mpp.intensity = mpp.intensity) #getOption("device")() plot(z) readline("press return") } par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1]) ############################################################# ## ## ## Example 2: A max-stable random field ## ## ## ############################################################# ### Smith's Gaussian extremal process x <- GridTopology(0, .1, 500) z <- RFsimulate(RPsmith(RMgauss()), x=x, n=10) plot(z, nmax=3) z <- as.vector(as.matrix(z@data)) par(mfcol=c(2,1)) plot(pmin(15, z[1:min(length(z), 1000)]), type="l") hist(ylim=c(0,1), pmin(z,5), 200, freq=FALSE) xx <- seq(0,4,len=1000) lines(xx, exp(-1/xx) / xx^2) ## a more complicated mixed moving maximum process model <- RPsmith(RMmppplus(RMgauss(), RMexp(), p=c(0.3, 0.7))) z <- RFsimulate(model, x=x, n=10) plot(z, nmax=1, ylim=c(0, 15)) z<-as.vector(as.matrix(z@data)) par(mfcol=c(2,1)) plot(pmin(15, z[1:min(length(z), 1000)]), type="l") hist(ylim=c(0,1), pmin(z,5), 200, freq=FALSE) xx <- seq(0,4,len=1000) lines(xx, exp(-1/xx) / xx^2) ## there are different possibilities to define a max-stable process: ## * m[[1]] below is a detailed way of defining a model. ## * m[[2]] is the same as m[[1]] as only one component is given ## * m[[3]] uses the fact that the standard schlather model is based ## on a Gaussian random field. So, it suffices to pass the ## covariance model m <- list(RMmppplus(RPgauss(RMgauss())), RPgauss(RMgauss()), RMgauss()) x <- GridTopology(0, .1, 500) for (i in 1:3){ %# same seed always z <- RFsimulate(model=Schlather(m[[i]]),x=x, n=2, seed=0) plot(z, nmax=1, ylim=c(0, 15)) z <- as.vector(as.matrix(z@data)) par(mfcol=c(2,1)) plot(pmin(10, z[1:min(length(z), 1000)]), type="l") hist(ylim=c(0,1), pmin(z,5), 200, freq=FALSE) xx <- seq(0,4,len=1000) lines(xx, exp(-1/xx) / xx^2) print(quantile(as.vector(z), probs=seq(0,1,0.05))) } ## mixture of extremal Gaussian models: x <- GridTopology(0, .03, 500) model <- RMmppplus(RPgauss(RMgauss()), RPgauss(RMexp()), p = c(0.7, 0.3)) z <- RFsimulate(model = Schlather(model), x=x, gauss.meth="sp", n=1) plot(z) z <- as.vector(as.matrix(z@data)) par(mfcol=c(2,1)) plot(pmin(1000, z[1:min(length(z), 1001)]), type="l") hist(ylim=c(0,1), pmin(z, 5), 200, freq=FALSE) xx <- seq(0,4,len=1000) lines(xx, exp(-1/xx) / xx^2) print(summary(z)) ## non-separable space-time model applied for two space dimensions ## note that tbm method works in some special cases. x <- y <- seq(0, 7, 0.05) T <- c(1,32,1) * 10 ## note necessarily gridtriple definition model <- RMnsst(aniso=diag(c(3, 3, 0.02)), delta=2, phi=RMgauss(), psi=RMgenfbm(alpha=1, delta=0.5)) z <- RFsimulate(x=x, y=y, T=T, model=model, method="ci", CE.strategy=1, CE.trials=4) rl <- function() readline("Press return") for (i in 1:dim(z)[3]) { image(z[,,i], zlim=range(z)); rl();} for (i in 1:dim(z)[2]) { image(z[,i,], zlim=range(z)); rl();} for (i in 1:dim(z)[1]) { image(z[i,,], zlim=range(z)); rl();} ############################################################# ## Example 3 shows the benefits from stored, ## ## intermediate results: in case of the circulant ## ## embedding method, the speed is doubled in the second ## ## simulation. ## ############################################################# RFoptions(storing=TRUE) y <- x <- seq(0, 50, 0.1) (p <- c(runif(3), runif(1)+1)) ut <- system.time(f <- RFsimulate(RPcirculant(RMexp())), x=x, y=y) % method="circ", param=p)) plot(f) %hist(f) %c( mean(as.vector(f)), var(as.vector(f)) ) cat("system time (first call)", format(ut,dig=3),"\n") # second call with the same paramters can be much faster: ut <- system.time(f <- RFsimulate()) plot(f) %hist(f) %c( mean(as.vector(f)), var(as.vector(f)) ) cat("system time (second call)", format(ut,dig=3),"\n") ############################################################# ## ## ## Example 4: how the cutoff method can be set ## ## explicitly using hypermodels ## ## ## ############################################################# ## NOTE: this feature is still in an experimental stage ## which has not been yet tested intensively; ## further: arguments and algorithms may change in ## future. ## simuation of the stable model using the cutoff method x <- seq(0, 1, 1/24) # nicer pictures with 1/240 scale <- 1.0 model1 <- RPcutoff(RMstable(alpha=1, scale=scale)) rs <- get(".Random.seed", envir=.GlobalEnv, inherits = FALSE) z1 <- RFsimulate(x, x, model=model1, n=1, storing=TRUE) (size <- RFgetRegisterInfo(meth=c("cutoff", "circ"))$S$size) cut.off.param <- RFgetRegisterInfo(meth=c("cutoff", "circ"), modelname="cutoff")$param print(cut.off.param) plot(z1) ## simulation of the same random field using the circulant ## embedding method and defining the hypermodel explicitely model2 <- RMcutoff(scale = scale, diam=cut.off.param$diam, a=cut.off.param$a, RMstable(alpha=1.0)) assign(".Random.seed", rs, envir=.GlobalEnv) z2 <- RFsimulate(x, x, gridtriple=FALSE, model=model2, meth="circulant", n=1, CE.mmin=size, Storing=TRUE) image(x, x, z2) Print(range(z1-z2)) ## essentially no difference between the fields! ############################################################# ## Example 5: ## ## The cutoff method simulates on a torus and a (small) ## ## rectangle is taken as the required simulation. ## ## ## ## The following code shows a whole such torus. ## ## The main part of the code sets local.dependent=TRUE and ## ## local.mmin to multiples of the basic rectangle lengths ## ############################################################# # definition of the realisation RFoptions(circulant.useprimes=FALSE) x <- seq(0, 2, len=4) # better 20 y <- seq(0, 1, len=5) # better 40 grid.size <- c(length(x), length(y)) model <- RMexp(var=1.1, aniso=matrix(nc=2, c(2, 1, 0.5, 1))) # determination of the (minimal) size of the torus InitRFsimulate(x, y, model=model, method="cutoff") ce.info.size <- RFgetRegisterInfo(meth=c("cutoff", "circ"))$S$size blocks <- ceiling(ce.info.size / grid.size / 4) *4 (size <- blocks * grid.size) # simulation and plot of the torus z <- RFsimulate(x, y, model=model, method="cu", n=prod(blocks) * 2, local.dependent=TRUE, local.mmin=size)[,,c(TRUE, FALSE)] height <- 8 ScreenDevice(height=height, width=height / blocks[2] / diff(range(y)) * blocks[1] * diff(range(x)))) close.screen(all = TRUE) sc <- matrix(nc=blocks[1], split.screen(rev(blocks)), byrow=TRUE) sc <- as.vector(t(sc[nrow(sc):1, ])) for (i in 1:prod(blocks)) { screen(sc[i]) par(mar=rep(1, 4) * 0.0) image(z[,, i], zlim=c(-3, 3), axes=FALSE, col=rainbow(100)) } % folgender Befehl muss unbedingt drin bleiben close.screen(all = TRUE) }} \dontshow{FinalizeExample()}}RandomFields/man/RMfixed.Rd0000644000176200001440000000236213437301604015225 0ustar liggesusers\name{RMfixed} \alias{RMfixed} \title{Fixed Effect Model} %\usage{ %} \description{Expressions of the form \code{X@RMfixed(beta)} can be used within a formula of the type \deqn{response ~ fixed effects + random effects + error term} that specifies the Linear Mixed Model. Important remark: \code{RMfixed} is NOT a function although the parentheses notation is used to specify the vector of coefficients. The matrix \eqn{X} is the design matrix and \eqn{\beta} is a vector of coefficients. Note that a fixed effect of the form \eqn{X} is interpreted as \code{X@RMfixed(beta=NA)} by default (and \eqn{\beta} is estimated provided that the formula is used in \command{\link{RFfit}}). Note that the \code{1} in an expression \code{1@RMfixed(beta)} is interpreted as the identity matrix. } %\arguments{ %} %\value{ %} %\references{Chiles, J. P., Delfiner, P. (1999) \emph{Geostatistics: % Modelling Spatial Uncertainty.} New York: John Wiley & Sons. %} \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFformula}}, \command{\link{RFsimulate}}. } \examples{\dontshow{StartExample()} ## For examples see the help page of 'RFformula'. ## \dontshow{FinalizeExample()}} \keyword{models} RandomFields/man/RMmppplus.Rd0000644000176200001440000000312513437301604015624 0ustar liggesusers\name{RMmppplus} \alias{RMmppplus} \alias{++} \title{Mixture of shape functions} \description{ \command{\link{RMmppplus}} is a multivariate covariance model which depends on up to 10 submodels \eqn{C_0, C_1, ..., C_9}. Used together with \command{\link{RPsmith}}, it allows for mixed moving maxima with a finite number of shape functions. } \usage{ RMmppplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, p)%, var,scale,Aniso,proj) } \arguments{ \item{C0}{an \command{\link{RMmodel}}} \item{C1,C2,C3,C4,C5,C6,C7,C8,C9}{optional; each an \command{\link{RMmodel}}} \item{p}{vector of probabilities for the shape functions. The probabilities should add up to 1. The length of the vector equals the number of given submodels.} % \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above model remains unmodified.} } \value{ \command{\link{RMmppplus}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMplus}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RPsmith}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again %\dontshow{StartExample()} %\dontshow{\dontrun{ %model <- RPcoins(RMmppplus(p=c(0.8, 0.2), RMgauss(), RMexp()), intensity=1) %x <- seq(0, 10, 0.02) %plot(RFsimulate(model, x=x)) %}} \dontshow{FinalizeExample()}} RandomFields/man/RRgauss.Rd0000644000176200001440000000223213437301604015251 0ustar liggesusers\name{RRgauss} \alias{RRgauss} \title{Vector Of Independent Gaussian Random Variables} \description{ \command{RRgauss} defines the d-dimensional vector of independent Gaussian random variables. } \usage{ RRgauss(mu, sd, log) } \arguments{ \item{mu, sd, log}{see \link[stats]{Normal}. Here, the components can be vectors, leading to multivariate distibution with independent components.} } \value{ \command{\link{RRgauss}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ It has the same effect as \code{\link{RRdistr}(\link[=rnorm]{norm}(mu=mu, sd=sd, log=log))}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RRdistr}}, \command{\link{RRunif}}. Do not mix up \command{RRgauss} with \command{\link{RMgauss}} or \command{\link{RPgauss}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again r <- RFrdistr(RRgauss(mu=c(1,5)), n=1000, dim=2) plot(r[1,], r[2, ]) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMstable.Rd0000644000176200001440000000645613437301604015410 0ustar liggesusers\name{RMstable} \alias{RMstable} \alias{powered exponential} \alias{RMpoweredexp} \alias{RMpoweredexponential} \title{Stable Family / Powered Exponential Model} \description{ \command{\link{RMstable}} is a stationary isotropic covariance model belonging to the so called stable family. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = e^{-r^\alpha}}{C(r)=e^{-r^\alpha}} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2}. } \usage{ RMstable(alpha, var, scale, Aniso, proj) RMpoweredexp(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The parameter \eqn{\alpha}{\alpha} determines the fractal dimension \eqn{D}{D} of the Gaussian sample paths: \deqn{ D = d + 1 - \frac{\alpha}{2}}{D = d + 1 - \alpha/2} where \eqn{d}{d} is the dimension of the random field. For \eqn{\alpha < 2}{\alpha < 2} the Gaussian sample paths are not differentiable (cf. Gelfand et al., 2010, p. 25). Each covariance function of the stable family is a normal scale mixture. The stable family includes the exponential model (see \command{\link{RMexp}}) for \eqn{\alpha = 1}{\alpha = 1} and the Gaussian model (see \command{\link{RMgauss}}) for \eqn{\alpha = 2}{\alpha = 2}. The model is called stable, because in the 1-dimensional case the covariance is the characteristic function of a stable random variable (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 90). } \value{ \command{\link{RMstable}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Covariance function \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. \item Diggle, P. J., Tawn, J. A. and Moyeed, R. A. (1998) Model-based geostatistics (with discussion). \emph{Applied Statistics} \bold{47}, 299--350. \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. } Tail correlation function (for \eqn{\alpha \in (0,1]}{0 < \alpha \le 1}) \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \me \seealso{ \command{\link{RMbistable}}, \command{\link{RMexp}}, \command{\link{RMgauss}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(alpha=1.9, scale=0.4) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMhyperbolic.Rd0000644000176200001440000000616613437301604016274 0ustar liggesusers\name{RMhyperbolic} \alias{RMhyperbolic} \title{Generalized Hyperbolic Covariance Model} \description{ \command{\link{RMhyperbolic}} is a stationary isotropic covariance model called \dQuote{generalized hyperbolic}. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = \frac{(\delta^2+r^2)^{\nu/2} K_\nu(\xi(\delta^2+r^2)^{1/2})}{\delta^\nu K_\nu(\xi \delta)}}{C(r) = \delta^(-\nu) (K_\nu(\nu \delta))^{-1} (\delta^2+r^2)^{\nu/2} K_\nu(\xi(\delta^2+r^2)^{1/2})} where \eqn{K_{\nu}}{K_\nu} denotes the modified Bessel function of second kind. } \usage{ RMhyperbolic(nu, lambda, delta, var, scale, Aniso, proj) } \arguments{ \item{nu, lambda, delta}{numerical values; should either satisfy\cr \eqn{\delta \ge 0}{\delta \ge 0}, \eqn{\lambda > 0}{\lambda > 0} and \eqn{\nu > 0}{\nu > 0}, or\cr \eqn{\delta > 0}{\delta > 0}, \eqn{\lambda > 0}{\lambda > 0} and \eqn{\nu = 0}{\nu = 0}, or\cr \eqn{\delta > 0}{\delta > 0}, \eqn{\lambda \ge 0}{\lambda \ge 0} and \eqn{\nu < 0}{\nu < 0}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This class is over-parametrized, i.e. it can be reparametrized by replacing the three parameters \eqn{\lambda}{\lambda}, \eqn{\delta}{\delta} and scale by two other parameters. This means that the representation is not unique. Each generalized hyperbolic covariance function is a normal scale mixture. The model contains some other classes as special cases; for \eqn{\lambda = 0}{\lambda = 0} we get the Cauchy covariance function (see \command{\link{RMcauchy}}) with \eqn{\gamma = -\frac{\nu}2}{\gamma = -\nu/2} and scale=\eqn{\delta}{\delta}; the choice \eqn{\delta = 0}{\delta = 0} yields a covariance model of type \command{\link{RMwhittle}} with smoothness parameter \eqn{\nu}{\nu} and scale parameter \eqn{\lambda^{-1}}{1/\lambda}. } \value{ \command{\link{RMhyperbolic}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Shkarofsky, I.P. (1968) Generalized turbulence space-correlation and wave-number spectrum-function pairs. \emph{Can. J. Phys.} \bold{46}, 2133-2153. \item Barndorff-Nielsen, O. (1978) Hyperbolic distributions and distributions on hyperbolae. \emph{Scand. J. Statist.} \bold{5}, 151-157. \item Gneiting, T. (1997). Normal scale mixtures and dual probability densities. \emph{J. Stat. Comput. Simul.} \bold{59}, 375-384. } } \me \seealso{ \command{\link{RMcauchy}}, \command{\link{RMwhittle}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}.} \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMhyperbolic(nu=1, lambda=2, delta=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RFgui.Rd0000644000176200001440000000654013437301604014705 0ustar liggesusers\name{RFgui} \alias{RFgui} \title{Graphical User Interface For Fitting Covariance Models And Variograms} \description{ This is a nice instructive graphical tool useful in particular for teaching classes } \usage{ RFgui(data, x, y, same.algorithm = TRUE, ev, bin = NULL, xcov, ycov, sim_only1dim=FALSE, wait = 0, ...) } \arguments{ \item{data}{See \command{\link{RFvariogram}}. If \code{data} is given, the empirical variogram is shown.} \item{x}{a \code{\link[base]{seq}}uence of the locations of the simulated process; if not given, \code{x} is determined by \code{data} and if \code{data} is not given by default values} \item{y}{a \code{\link[base]{seq}}uence of numbers if a simulation on \eqn{R^d} is performed. Default is \code{y = x}; see \code{x} for details.} \item{same.algorithm}{Force the picture being simulated with the same algorithm so that the pictures are always directly comparable. The disadvantage is that some models are simulated only (very) approximatively.} \item{ev}{instead of the data, the empirical variogram itself might be passed} \item{bin}{only considered if \code{data} is given. See \command{\link{RFvariogram}} for details. } \item{xcov}{ \code{\link[base]{seq}}uence of the locations where the covariance function is plotted} \item{ycov}{Only for anisotropic models. \code{\link[base]{seq}}uence of the locations where the covariance function is also plotted} \item{sim_only1dim}{Logical. The argument determines whether a process should be simulated on the line or on the plane} \item{wait}{integer. See details. } \item{...}{further options and control arguments for the simulation that are passed to and processed by \command{\link{RFoptions}}.} } \details{ If \code{wait} is negative the xterm does not wait for the tkltk-window to be finished. Further the variable \code{RFgui.model} is created in the environment \code{.GlobalEnv} and contains the currently chosen variable in the gui. \command{\link{RFgui}} always returns \code{NULL}. If \code{wait} is non-negative the xterm waits for the tkltk-window to be finished. \command{\link{RFgui}} returns invisibly the last chosen model (or \code{NULL} if no model has been chosen). \command{\link{RFgui}} idles a lot when \code{wait=0}. It idles less for higher values by sleeping about \code{wait} microseconds. Of course the handling in the tkltk window gets slower as well. Reasonable values for \code{wait} are within \code{[0,1000]}. \cite{same.alg = TRUE} is equivalent to setting \code{circulant.trials=1}, \code{circulant.simu_method = "RPcirculant"}, \code{circulant.force=TRUE}, \code{circulant.mmin=-2}. } \value{ If \code{wait < 0} the function returns \code{NULL} else it returns the last chosen \command{\link{RMmodel}}. If \code{wait < 0}, a side effect of \command{\link{RFgui}} is the creation of the variable \code{RFgui.model} on \code{.GlobalEnv}. } \author{\martin \subsection{Author(s) of the code}{Daphne Boecker; \martin} } \seealso{ \code{\link{soil}} for a further example } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgui() \dontshow{FinalizeExample()} } RandomFields/man/RFfit.Rd0000644000176200001440000001460213437301604014701 0ustar liggesusers\name{RFfit} \alias{RFfit} %\alias{mleRF}% obsolete \alias{RFfit.default} \title{Fitting model parameters to spatial data (regionalised variables) and to linear (mixed) models} \description{ The function estimates arbitrary parameters of a random field specification with various methods. Currently, the models to be fitted can be \itemize{ \item{\link[=RPgauss]{Gaussian random fields}} \item{\link[=RFformula]{linear models}} } The fitting of max-stable random fields and others has not been implemented yet. } \usage{ RFfit(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, params=NULL, ...) } \arguments{ \item{model,params}{\argModel All parameters that are set to \code{NA} will be estimated; see the examples below. Type \code{\link{RFgetModelNames}(type="variogram")} to get all options for \code{model}. } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{data}{\argData} \item{lower}{\argLower} \item{upper}{\argUpper} \item{methods}{\argFitmethods} \item{sub.methods}{\argFitsubmethods. See Details.} \item{users.guess}{\argUsersguess} \item{distances,dim}{\argDistances} \item{optim.control}{\argOptimcontrol} \item{transform}{\argTransform} \item{...}{\argDots} } \details{ For details on the simulation methods see \itemize{ \item \link{fitgauss} for \link[=RPgauss]{Gaussian random fields} \item \link{fitgauss} for \link[=RFformula]{linear models} } If \code{x}-coordinates are not given, the function will check \code{data} for \code{NA}s and will perform imputing. The function has many more options to tune the optimizer, see \command{\link{RFoptions}} for details. If the model defines a Gaussian random field, the options for \code{methods} and \code{submethods} are currently \code{"ml"} and \code{c("self", "plain", "sqrt.nr", "sd.inv", "internal")}, respectively. } \note{ \itemize{ \item An important optional argument is \code{boxcox} which indicates a Box-Cox transformation; see \code{boxcox} in \command{\link{RFoptions}} and \code{RFboxcox} for details. \item Instead of \command{\link[stats]{optim}}, other optimisers can be used, see \link{RFfitOptimiser}. \item Several advanced options can be found in sections \sQuote{General options} and \sQuote{fit} of \command{\link{RFoptions}}. \item In particular, \code{boxcox}, \code{boxcox_lb}, \code{boxcox_ub} allow Box-Cox transformation. \item This function does not depend on the value of \command{\link{RFoptions}}\code{()$PracticalRange}. The function \code{RFfit} always uses the standard specification of the covariance model as given in \command{\link{RMmodel}}. } } \value{ The result depends on the logical value of \code{\link[=RFoptions]{spConform}}. If \code{TRUE}, an S4 object is created. In case the model indicates a Gaussian random field, an \link[=RFfit-class]{RFfit} object is created. If \code{spConform=FALSE}, a list is returned. In case the model indicates a Gaussian random field, the details are given in \link{fitgauss}. } \references{ \itemize{ \item Burnham, K. P. and Anderson, D. R. (2002) \emph{Model selection and Multi-Model Inference: A Practical Information-Theoretic Approach.} 2nd edition. New York: Springer. } } \me \seealso{ \command{\link{RFfitOptimiser}}, \command{\link{RFlikelihood}}, \command{\link{RFratiotest}}, \command{\link{RMmodel}}, \code{\link[=RandomFields-package]{RandomFields}}, \command{\link{weather}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again % options(error=recover) % source("RandomFields/tests/source.R") % to do bsp mit box cox RFoptions(modus_operandi="sloppy") ######################################################### ## simulate some data first ## points <- 100 x <- runif(points, 0, 3) y <- runif(points, 0, 3) ## random points in square [0, 3]^2 model <- RMgencauchy(alpha=1, beta=2) d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=100) #1000 ######################################################### ## estimation; 'NA' means: "to be estimated" ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) + RMtrend(mean=NA) RFfit(estmodel, data=d) ######################################################### ## coupling alpha and beta ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) + RMtrend(NA) RFfit(estmodel, data=d, transform = NA) ## just for information trafo <- function(a) c(a[1], rep(a[2], 2)) fit <- RFfit(estmodel, data=d, transform = list(c(TRUE, TRUE, FALSE), trafo)) print(fit) print(fit, full=TRUE) \dontshow{\dontrun{ ######################################################### ## Estimation with fixed sill (variance + nugget ## ## equals a given constant) ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) + RMnugget(var=NA) + RMtrend(mean=NA) RFfit(estmodel, data=d, fit.sill=1, fit.optim_var_elimination="try") ######################################################### ## estimation in a anisotropic framework ## x <- y <- (1:3)/4 model <- RMexp(Aniso=matrix(nc=2, c(4,2,-2,1)), var=1.5) d <- RFsimulate(model, x=x, y=y, n=n) estmodel <- RMexp(Aniso=matrix(nc=2, c(NA,NA,-2,1)), var=NA) + RMtrend(mean=NA) RFfit(estmodel, data=d, fit.nphi=20) ######################################################### ## AN EXAMPLE HOW TO USE OF PARAMETER 'transform' ## ## estimation of coupled parameters (first column of ## ## the matrix 'Aniso' has identical entries) ## # source("RandomFields/tests/source.R") RFfit(estmodel, data=d, transform=list()) # shows positions of NAs f <- function(param) param[c(1,2,2)] RFfit(estmodel, data=d, transform=list(c(TRUE, TRUE, FALSE), f)) }} \dontshow{RFoptions(modus_operandi="normal")} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{optimize} RandomFields/man/RMbiwm.Rd0000644000176200001440000001021613437301604015061 0ustar liggesusers\name{RMbiwm} \alias{RMbiwm} \title{Full Bivariate Whittle Matern Model} \description{ \command{\link{RMbiwm}} is a bivariate stationary isotropic covariance model whose corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given for \eqn{i,j \in \{1,2\}}{i,j = 1,2} by \deqn{C_{ij}(r)=c_{ij} W_{\nu_{ij}}(r/s_{ij}).}{C_{ij}(r)=c_{ij} W_{\nu_{ij}}(r/s_{ij}).} Here \eqn{W_\nu} is the covariance of the \command{\link{RMwhittle}} model. For constraints on the constants see Details. } \usage{ RMbiwm(nudiag, nured12, nu, s, cdiag, rhored, c, notinvnu, var, scale, Aniso, proj) } \arguments{ \item{nudiag}{a vector of length 2 of numerical values; each entry positive; the vector \eqn{(\nu_{11},\nu_{22})}} \item{nured12}{a numerical value in the interval \eqn{[1,\infty)}; \eqn{\nu_{21}} is calculated as \eqn{0.5 (\nu_{11} + \nu_{22})*\nu_{red}}.} \item{nu}{alternative to \code{nudiag} and \code{nured12}: a vector of length 3 of numerical values; each entry positive; the vector \eqn{(\nu_{11},\nu_{21},\nu_{22})}. Either \code{nured} and \code{nudiag}, or \code{nu} must be given.} \item{s}{a vector of length 3 of numerical values; each entry positive; the vector \eqn{(s_{11},s_{21},s_{22})}.} \item{cdiag}{a vector of length 2 of numerical values; each entry positive; the vector \eqn{(c_{11},c_{22})}.} \item{rhored}{a numerical value; in the interval \eqn{[-1,1]}. See also the Details for the corresponding value of \eqn{c_{12}=c_{21}}. } \item{c}{a vector of length 3 of numerical values; the vector \eqn{(c_{11},c_{21}, c_{22})}. Either \code{rhored} and \code{cdiag} or \code{c} must be given.} \item{notinvnu}{logical or \code{NULL}. If not given (default) then the formula of the (\command{\link{RMwhittle}}) model applies. If logical then the formula for the \command{\link{RMmatern}} model applies. See there for details. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Constraints on the constants: For the diagonal elements we have \deqn{\nu_{ii}, s_{ii}, c_{ii} > 0.} For the offdiagonal elements we have \deqn{s_{12}=s_{21} > 0,} \deqn{\nu_{12} =\nu_{21} = 0.5 (\nu_{11} + \nu_{22}) * \nu_{red}} for some constant \eqn{\nu_{red} \in [1,\infty)} and \deqn{c_{12} =c_{21} = \rho_{red} \sqrt{f m c_{11} c_{22}}} for some constant \eqn{\rho_{red}} in \eqn{[-1,1]}. The constants \eqn{f} and \eqn{m} in the last equation are given as follows: \deqn{f = (\Gamma(\nu_{11} + d/2) \Gamma(\nu_{22} + d/2)) / (\Gamma(\nu_{11}) \Gamma(\nu_{22})) * (\Gamma(\nu_{12}) / \Gamma(\nu_{12}+d/2))^2 * ( s_{12}^{2*\nu_{12}} / (s_{11}^{\nu_{11}} s_{22}^{\nu_{22}}) )^2} where \eqn{\Gamma} is the Gamma function and \eqn{d} is the dimension of the space. The constant \eqn{m} is the infimum of the function \eqn{g} on \eqn{[0,\infty)} where \deqn{g(t) = (1/s_{12}^2 +t^2)^{2\nu_{12} + d} (1/s_{11}^2 + t^2)^{-\nu_{11}-d/2} (1/s_{22}^2 + t^2)^{-\nu_{22}-d/2}} (cf. Gneiting, T., Kleiber, W., Schlather, M. (2010), Full Bivariate Matern Model (Section 2.2)). % For an alternative model see also \command{\link{RMbiwm}}. } \value{ \command{\link{RMbiwm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T., Kleiber, W., Schlather, M. (2010) Matern covariance functions for multivariate random fields \emph{JASA} } } \me \seealso{ \command{\link{RMparswm}}, \command{\link{RMwhittle}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \link{Multivariate RMmodels}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10, 10, 0.2) model <- RMbiwm(nudiag=c(0.3, 2), nured=1, rhored=1, cdiag=c(1, 1.5), s=c(1, 1, 2)) plot(model) plot(RFsimulate(model, x, y)) \dontshow{FinalizeExample()}}RandomFields/man/RMpolynome.Rd0000644000176200001440000000227413437301604015772 0ustar liggesusers\name{RMpolynome} \alias{RMpolynome} \title{Creating polynomial models} \description{ Polynomials, mainly used in trend models, can be created easily with this function. } \usage{ RMpolynome(degree, dim, value=NA, coordnames = c("x", "y", "z", "T"), proj=1:4) } \arguments{ \item{degree}{degree of the polynome } \item{dim}{number of variables in the polynome } \item{value}{ values of the coefficients. See Details. } \item{coordnames}{the names of the variables } \item{proj}{the projection to certain dimensions } } \details{ If the length of \code{value} is smaller than the number of monomials, the remaining terms are filled with \code{NA}s. If the length is larger, the vector is cut. } \value{ \command{\link{RMpolynome}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMtrend}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} ## For examples see the help page of 'RFformula' ## RMpolynome(1, 1) RMpolynome(1, 2) RMpolynome(2, 1) RMpolynome(2, 2) RMpolynome(3, 3) \dontshow{FinalizeExample()}}RandomFields/man/RFcrossvalidate.Rd0000644000176200001440000001124113437301604016756 0ustar liggesusers\name{RFcrossvalidate} \alias{RFcrossvalidate} \alias{print.crossvalidate} \alias{summary.crossvalidate} \alias{print.summary.crossvalidate} %\alias{mleRF}% obsolete \alias{RFcrossvalidate.default} \title{Fitting model parameters to spatial data (regionalised variables) and to linear (mixed) models} \description{ The function estimates arbitrary parameters of a random field specification with various methods. Currently, the models to be fitted can be \itemize{ \item{\link[=RPgauss]{Gaussian random fields}} \item{\link[=RFformula]{linear models}} } The fitting of max-stable random fields and others has not been implemented yet. } \usage{ RFcrossvalidate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, data, params, lower=NULL, upper=NULL, method="ml", users.guess=NULL, distances=NULL, dim, optim.control=NULL, transform=NULL, full = FALSE, ...) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{data}{\argData} \item{lower}{\argLower} \item{upper}{\argUpper} \item{method}{ Single method to be used for estimating, either one of the \code{methods} or one of the \code{sub.methods} see \command{\link{RFfit}} } \item{users.guess}{\argUsersguess} \item{distances,dim}{\argDistances} \item{optim.control}{\argOptimcontrol} \item{transform}{\argTransform} \item{full}{logical. If \code{TRUE} then cross-validation is also performed for intermediate models used in \code{RFfit} (if any). } \item{...}{\argDots} } \section{Methods}{ \describe{ \item{print}{prints the summary} \item{summary}{gives a summary} } } \note{ An important option is \code{cross_refit} that determines whether the model is refitted for each location left out. Default is \code{FALSE}. See also \command{\link{RFoptions}}. } \value{ An object of the \code{\link{class}} \code{"RFcrossvalidate"} which is a list with the following components, cf. \command{xvalid} in the package \pkg{geoR} : \item{data}{the original data. } \item{predicted}{the values predicted by cross-validation. } \item{krige.var}{the cross-validation prediction variance. } \item{error}{the differences \code{data - predicted value}. } \item{std.error}{the errors divided by the square root of the prediction variances. } \item{p}{ In contrast to \pkg{geoR} the p-value is returned, i.e. the probability that a difference with absolute value larger than the absolute value of the actual difference is observed. A method for \code{summary} returns summary statistics for the errors and standard errors similar to \pkg{geoR}. If \code{cross_refit = TRUE} and \code{detailed_output = TRUE} the returned object also contains a \code{fitted} which is a list of fitted models. } } \references{ \itemize{ \item Ribeiro, P.J., Jr. and Diggle, P.J (2014) R package \pkg{geoR}. \item Burnham, K. P. and Anderson, D. R. (2002) \emph{Model selection and Multi-Model Inference: A Practical Information-Theoretic Approach.} 2nd edition. New York: Springer. } } \me \note{This function does not depend on the value of \command{\link{RFoptions}}\code{()$PracticalRange}. The function \code{RFcrossvalidate} always uses the standard specification of the covariance model as given in \command{\link{RMmodel}}. } \seealso{ \command{\link{RFratiotest}} \command{\link{RFfit}} \command{\link{RMmodel}}, \code{\link[=RandomFields-package]{RandomFields}}, \command{\link{weather}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again % options(error=recover) % source("RandomFields/tests/source.R") ## currently disabled! \dontshow{\dontrun{ ## See also papers.jss14.rd !!!! RFoptions(modus_operandi="sloppy") ######################################################### ## simulate some data first points <- 100 x <- runif(points, 0, 3) y <- runif(points, 0, 3) ## random points in square [0, 3]^2 model <- RMgencauchy(alpha=1, beta=2) d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=n=100) #better n=1000 ######################################################### ## estimation; 'NA' means: "to be estimated" estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) + RMtrend(mean=NA) RFcrossvalidate(estmodel, data=d) }} \dontshow{RFoptions(modus_operandi="normal")} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RFvariogram.Rd0000644000176200001440000000750313437301604016110 0ustar liggesusers\name{RFvariogram} \alias{RFvariogram} \title{Empirical (Cross-)Variogram} \description{ Calculates empirical (cross-)variogram. } \usage{ RFvariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} \item{data}{\argData} \item{bin}{\argBin} \item{phi}{\argPhi} \item{theta}{\argTheta} \item{deltaT}{\argDeltaT} \item{vdim}{\argVdim} } \details{ \command{\link{RFvariogram}} computes the empirical cross-variogram for given (multivariate) spatial data. The empirical (cross-)variogram of two random fields \eqn{X}{X} and \eqn{Y}{Y} is given by \deqn{\gamma(r):=\frac{1}{2N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})-X(t_{j}))(Y(t_{i})-Y(t_{j}))}{\gamma(r):=1/2N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})-X(t_{j}))(Y(t_{i})-Y(t_{j}))} where \eqn{t_{i,j}:=t_{i}-t_{j}}{t_{i,j}:=t_{i}-t_{j}}, and where \eqn{N(r)}{N(r)} denotes the number of pairs of data points with distancevector \eqn{t_{i,j}=r}{t_{i,j}=r}. The spatial coordinates \code{x}, \code{y}, \code{z} should be vectors. For random fields of spatial dimension \eqn{d > 3} write all vectors as columns of matrix x. In this case do neither use y, nor z and write the columns in \code{gridtriple} notation. If the data is spatially located on a grid a fast algorithm based on the fast Fourier transformed (fft) will be used. As advanced option the calculation method can also be changed for grid data (see \command{\link{RFoptions}}.) } \value{ \command{\link{RFvariogram}} returns objects of class \command{\link[=RFempVariog-class]{RFempVariog}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \author{Sebastian Engelke; Johannes Martini; \martin} \seealso{ \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFcov}}, \command{\link{RFpseudovariogram}}. \command{\link{RFmadogram}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFvariogram(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFvariogram(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMmqam.Rd0000644000176200001440000000527713437301604015071 0ustar liggesusers\name{RMmqam} \alias{RMmqam} \alias{RMmqam} \title{multivariate quasi-arithmetic mean} \description{ \command{\link{RMmqam}} is a multivariate stationary covariance model depending on a submodel \eqn{\phi}{phi} such that \eqn{\psi(\cdot) := \phi(\sqrt(\cdot))}{psi( . ) := phi(sqrt( . ))} is completely monotone, and depending on further stationary covariance models \eqn{C_i}. The covariance is given by \deqn{C_{ij}(h) = \phi(\sqrt(\theta_i (\phi^{-1}(C_i(h)))^2 + \theta_j (\phi^{-1}(C_j(h)))^2 ))} where \eqn{\phi} is a completely monotone function, \eqn{C_i} are suitable covariance functions and \eqn{\theta_i\ge0} such that \eqn{\sum_i \theta_i=1}. } \usage{ RMmqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj) } \arguments{ \item{phi}{a valid covariance \command{\link{RMmodel}} that is a normal scale mixture. See, for instance, \cr \code{\link{RFgetModelNames}(monotone="normal mixture")} } \item{C1, C2, C3, C4, C5, C6, C7, C8, C9}{optional further stationary \command{\link{RMmodel}}s} \item{theta}{is a vector of values in \eqn{[0,1]}, summing up to \eqn{1}.} % \item{rho}{a matrix with positive entries} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Note that \eqn{\psi(\cdot) := \phi(\sqrt(\cdot))}{psi( . ) := phi(sqrt( . ))} is completely monotone if and only if \eqn{\phi}{phi} is a valid covariance function for all dimensions, e.g. \command{\link{RMstable}}, \command{\link{RMgauss}}, \command{\link{RMexponential}}. Warning: \code{RandomFields} cannot check whether the combination of \eqn{\phi}{phi} and \eqn{C_i} is valid. } \value{ \command{\link{RMmqam}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Porcu, E., Mateu, J. & Christakos, G. (2009) Quasi-arithmetic means of covariance functions with potential applications to space-time data. \emph{Journal of Multivariate Analysis}, \bold{100}, 1830--1844. } } \me \seealso{ \command{\link{RMqam}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") model <- RMmqam(phi=RMgauss(),RMgauss(),RMexp(),theta=c(0.4, 0.6), scale=0.5) x <- seq(0, 10, 0.02) plot(model) z <- RFsimulate(model=model, x=x) plot(z) RFoptions(modus_operandi="normal") \dontshow{FinalizeExample()}}RandomFields/man/RPmaxstableAdvanced.Rd0000644000176200001440000000663213437301604017543 0ustar liggesusers\name{Max-stable random fields, advanced } \alias{maxstableAdvanced} \alias{RPmaxstableAdvanced} \title{Simulation examples of advanced Max-Stable Random Fields} \description{ Here, an advanced example is given used to test whether the algorithms work correctly. } %\details{ %} \references{ Strokorb, K. (2013) Ph.D. thesis. } \seealso{ \command{\link{RPmaxstable}} } \me \keyword{spatial} \examples{\dontshow{StartExample()}%\dontshow{StartExample(reduced=50)} \dontshow{\dontrun{ RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 100 model <- RMexp(var=1.62 / 2) x <- seq(0, 5, 0.2) y <- seq(0, 10, 0.2) auswertung <- function(simu, model, threshold=2) { x <- as.vector(coordinates(simu)) simu <- as.array(simu) below <- simu <= threshold freq <- rowMeans(below) meanfreq <- mean(freq) Print(freq, meanfreq, exp(-1/threshold)) ## univariate kontrolle both <- t(below) & below[1, ] ecf <- 2-log(colMeans(both)) / log(meanfreq) plot(x, ecf) ## alle 3 Linien ergeben das Gleiche: spC <- RFoptions()$general$spConform RFoptions(spConform = FALSE) lines(x, m1 <- RFcov(RMbrownresnick(model), x), col="yellow") lines(x, m2 <- RFcov(RMschlather(RMbr2eg(model)), x), col="red", lty=2) # OK m3 <- RFcov(RMbernoulli(RMbr2bg(model), centred=FALSE), x) lines(x, m3, col="blue", lty=3) RFoptions(spConform = spC) erfc <- function(x) 2 * pnorm(x, 0, sd=1/sqrt(2), lower=FALSE) lines(x, m4 <- erfc(0.45 * sqrt(1-exp(-x))), lty=4) ## theoretical curves correct? if (!all.equal(m1, m2) || !all.equal(m1, m3) || !all.equal(m1, m4)) stop("calculation error") if ( (n <- ncol(simu)) >= 1000) { ## margins correct? mar.threshold <- 4 * 0.5 / sqrt(n) mmar.threshold <- 3 * 0.5 / sqrt(n) Print(abs(freq - exp(-1/threshold)), mar.threshold) if (abs(freq[sample(length(freq), 1)] - exp(-1/threshold)) > mar.threshold) stop("marginal distribution wrong? (single margin)") if (abs(meanfreq - exp(-1/threshold)) > mmar.threshold) stop("marginal distribution wrong? (mean margin)") ## extremal correlation function correct? meanthreshold <- 4 / sqrt(n) maxthreshold <- 2 * sqrt(nrow(simu)) / sqrt(n) Print(abs(ecf - m1), meanthreshold, maxthreshold) if (mean(abs(ecf - m2)) > meanthreshold) stop("ecf not correct? (mean deviation too large)") if (max(abs(ecf - m2)) > maxthreshold) stop("ecf not correct? (max deviation too large)") } } ## BR currently not programmed \dontshow{\dontrun{ ## to to ## Brown-Resnick z <- RFsimulate(RPbrownresnick(model), y, y) plot(z) simu <- RFsimulate(RPbrownresnick(model), x, n=n, max_gauss=5) auswertung(simu, model) }} %\dontshow{\dontrun{ ## Windows hat Fehler. Unklar wieso ## Extremal Gaussian z <- RFsimulate(RPschlather(RMbr2eg(model)), y, y) plot(z) simu <- RFsimulate(RPschlather(RMbr2eg(model)), x, n=n) auswertung(simu, model) ## Extremal Binary Gaussian binary.model <- RPbernoulli(RMbr2bg(model)) z <- RFsimulate(RPschlather(binary.model), y, y) plot(z) simu <- RFsimulate(RPschlather(binary.model), x, n=n, max_gauss=5) auswertung(simu, model) \dontshow{\dontrun{ ## OK! zaehler <- 0 repeat { Print(zaehler) zaehler <- zaehler + 1 simu <- RFsimulate(RPschlather(RMbr2eg(model)), x, spConform=FALSE, n=n, pch="") auswertung(simu, model) } }} }} \dontshow{FinalizeExample()} }RandomFields/man/RMSadvanced.Rd0000644000176200001440000000551313437301604016017 0ustar liggesusers\name{RMSadvanced} \alias{RMSadvanced} \title{Scaling operator -- comments for advanced applications} \description{ Here advances uses are given for the arguments \code{var}, \code{scale}, \code{Aniso}, \code{proj} that are available to most of the models } \section{Usage}{ RMS(phi, var, scale, Aniso, proj, anisoT) } \section{Arguments}{ \describe{ \item{phi}{submodel} \item{var}{Instead of a constant it can be also an arbitrary non-negative function, see \code{\link{R.}} and \command{\link{RMuser}} for defining arbitrary functions. } \item{scale}{instead of a positive constant it can be an arbitrary, positive deterministic function. In case of the latter, the scale should be given by one of the functions \command{\link{RMbubble}} or \command{\link{RMscale}}. In case none of them are given, \command{\link{RMscale}} is assumed with scale penality \eqn{\|s(x) - s(y)\|^2} for the square of the norm. The scale can be also a random variable in case of Bayesian modelling. } \item{Aniso}{matrix or \code{\link{RMmodel}}. Instead of a matrix, \code{Aniso} can be an arbitrary, vector-valued function . } \item{proj}{is the optional projection vector which defines a diagonal matrix of zeros and ones and \code{proj} gives the positions of the ones (integer values between 1 and the dimension of \eqn{x}). It also allows for the values \code{'space'} and \code{'time'} in case of space-time modelling. } \item{anisoT}{the transpose of the anisotropy matrix \eqn{B}, multiplied from the left by a distance vector \eqn{x}, i.e. \eqn{x^\top B}. } } } \section{Details}{ See the reference for Gneitings nsst model used for modelling scales. See also the example below. } \section{Value}{ \command{\link{RMSadvanced}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation. } } \me \seealso{ \command{\link{RMS}}, \command{\link{RMblend}} for a different approach on modelling different scales } \examples{\dontshow{StartExample(FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMfbm.Rd0000644000176200001440000000441113437301604014667 0ustar liggesusers\name{RMfbm} \alias{RMfbm} \title{Variogram Model of Fractal Brownian Motion} \description{ \command{\link{RMfbm}} is an intrinsically stationary isotropic variogram model. The corresponding centered semi-variogram only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{\gamma(r) = r^\alpha}{\gamma(r) = r^\alpha} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2}.\cr By now, the model is implemented for dimensions up to 3.\cr For a generalized model see also \command{\link{RMgenfbm}}. } \usage{ RMfbm(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{numeric in \eqn{(0,2]}; refers to the fractal dimension of the process} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above variogram remains unmodified.} } \details{ The variogram is unbounded and belongs to a non-stationary process with stationary increments. For \eqn{\alpha=1}{\alpha=1} and \code{scale=2} we get a variogram corresponding to a standard Brownian Motion. For \eqn{\alpha \in (0,2)}{0 < \alpha < 2} the quantity \eqn{H = \frac{\alpha} 2}{H=\alpha/2} is called Hurst index and determines the fractal dimension \eqn{D} of the corresponding Gaussian sample paths \deqn{D = d + 1 - H} where \eqn{d}{d} is the dimension of the random field (see Chiles and Delfiner, 1999, p. 89). } \value{ \command{\link{RMfbm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and P. Delfiner (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York, Chichester: John Wiley & Sons. \item Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599. } } \me \seealso{ \command{\link{RMgenfbm}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfbm(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/sp2RF.Rd0000644000176200001440000000266413437301604014630 0ustar liggesusers\name{sp2RF} \alias{sp2RF} \title{Transformation of an 'sp' object to an 'RFsp' object} \description{ The function transforms an 'sp' object to an 'RFsp' object. This explicit transformation is only necessary if several variables and repeated measurements are given. } \usage{ sp2RF(sp, param=list(n=1, vdim=1)) } \arguments{ \item{sp}{an \sQuote{sp} object} \item{param}{\code{n}: number of repetitions; \code{vdim}: the number of variables (multivariability) } } \value{ \command{\link{sp2RF}} returns an object of class \code{\link[=RFsp-class]{RFsp}}. } \note{The two options \code{varnames} and \code{coordnames}, cf. section \sQuote{coords} in \command{\link{RFoptions}}, might be useful.} \me \seealso{ \command{\link[=RFsp-class]{RFsp}} } \keyword{spatial} \examples{\dontshow{StartExample(reduced=FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again p <- 100 n <- 5 x <- runif(p, 0, 1) y <- runif(p, 0, 1) z <- RFsimulate(RMexp(), x=x, y=y, n=n) z1 <- z2 <- as.data.frame(z) coordinates(z2) <- ~coords.x1 + coords.x2 (emp.var <- RFvariogram(data=z)) (emp.var1 <- RFvariogram(data=z1)) (emp.var2 <- RFvariogram(data=sp2RF(z2, param=list(n=n, vdim=1)))) stopifnot(all.equal(emp.var, emp.var1)) stopifnot(all.equal(emp.var, emp.var2)) \dontshow{FinalizeExample()} } RandomFields/man/RFgridDataFrame-class.Rd0000644000176200001440000001341213437301604017712 0ustar liggesusers\name{RFgridDataFrame-class} \docType{class} \alias{RFgridDataFrame-class} \alias{RFgridDataFrame} %% S4 methods \alias{RFspDataFrame2conventional,RFgridDataFrame-method} \alias{RFspDataFrame2dataArray,RFgridDataFrame-method} \alias{show,RFgridDataFrame-method} \alias{coerce,RFgridDataFrame,RFpointsDataFrame-method} \alias{coerce,RFgridDataFrame,RFpointsDataFrame,ANY-method} \alias{[,RFgridDataFrame-method} \alias{[,RFgridDataFrame,ANY,ANY-method} \alias{[,RFgridDataFrame,ANY,ANY,ANY-method} \alias{[<-,RFgridDataFrame-method} \alias{[<-,RFgridDataFrame,ANY,ANY,ANY-method} \alias{dimensions,RFgridDataFrame-method} %\alias{isGridded,RFgridDataFrame-method} \alias{variance,RFgridDataFrame-method} %% S3 methods \alias{print.RFgridDataFrame} \alias{cbind.RFgridDataFrame} \alias{range.RFgridDataFrame} \alias{hist.RFgridDataFrame} \alias{as.data.frame.RFgridDataFrame} \alias{as.matrix.RFgridDataFrame} \alias{as.array.RFgridDataFrame} \alias{as.vector.RFgridDataFrame} \alias{as.data.frame.RFgridDataFrame} \title{Class \code{RFgridDataFrame} } \description{ Class for attributes in one-dimensional space.} \usage{ \S4method{RFspDataFrame2conventional}{RFgridDataFrame}(obj, data.frame=FALSE) } \arguments{ \item{obj}{an \code{RFgridDataFrame} object} \item{data.frame}{logical. If \code{TRUE} a \code{data.frame} is returned. } } \section{Creating Objects}{ Objects can be created by using the functions \code{\link{RFgridDataFrame}} or \code{\link{conventional2RFspDataFrame}} or by calls of the form \code{as(x, "RFgridDataFrame")}, where \code{x} is of class \command{\link[=RFgridDataFrame-class]{RFgridDataFrame}}. %Ordered full grids are stored instead or unordered non-NA cells; } \section{Slots}{ \describe{ \item{\code{.RFparams}:}{list of up to 5 elements; \itemize{ \item{n} is the number of repetitions of the random field contained in the \code{data} slot \item \code{vdim} gives the dimension of the values of the random field, equals 1 in most cases \item \code{has.variance} indicates whether information on the variance is available, \item \code{coordunits} gives the names of the units for the coordinates \item \code{varunits} gives the names of the units for the variables } } \item{\code{data}:}{object of class \code{\link[methods:data.frame-class]{data.frame}}, containing attribute data } \item{\code{grid}:}{object of class \code{\link[sp:GridTopology-class]{GridTopology}}.} } } \section{Methods}{ \describe{ \item{plot}{\code{signature(obj = "RFgridDataFrame")}: generates nice plots of the random field; if \eqn{space-time-dim2}, a two-dimensional subspace can be selected using the argument \code{MARGIN}; to get different slices in a third direction, the argument \code{MARGIN.slices} can be used; for more details see \code{\link{plot-method}} or type \code{method?plot("RFgridDataFrame")}} \item{show}{\code{signature(x = "RFgridDataFrame")}: uses the \command{show}-method for class \code{\link[=SpatialGridDataFrame-class]{SpatialGridDataFrame}}.} \item{print}{\code{signature(x = "RFgridDataFrame")}: identical to \command{show}-method} \item{RFspDataFrame2conventional}{\code{signature(obj = "RFgridDataFrame")}: conversion to a list of non-\pkg{sp}-package based objects; the \code{data}-slot is converted to an array of dimension \eqn{[1*(vdim>1) + space-time-dimension + 1*(n>1)]}} \item{coordinates}{\code{signature(x = "RFgridDataFrame")}: returns the coordinates} \item{[}{\code{signature(x = "RFgridDataFrame")}: selects columns of \code{data}-slot; returns an object of class \code{\link[=RFgridDataFrame-class]{RFgridDataFrame}}.} \item{[<-}{\code{signature(x = "RFgridDataFrame")}: replaces columns of \code{data}-slot; returns an object of class \code{\link[=RFgridDataFrame-class]{RFgridDataFrame}}.} \item{as}{\code{signature(x = "RFgridDataFrame")}: converts into other formats, only implemented for target class \code{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}} } \item{cbind}{\code{signature(...)}: if arguments have identical topology, combine their attribute values} \item{range}{\code{signature(x = "RFgridDataFrame")}: returns the range } \item{hist}{\code{signature(x = "RFgridDataFrame")}: plots histogram } \item{as.matrix}{\code{signature(x = "RFgridDataFrame")}: converts \code{data}-slot to matrix} \item{as.array}{\code{signature(x = "RFgridDataFrame")}: converts \code{data}-slot to array} \item{as.vector}{\code{signature(x = "RFgridDataFrame")}: converts \code{data}-slot to vector} \item{as.data.frame}{\code{signature(x = "RFgridDataFrame")}: converts \code{data}-slot and coordinates to a data.frame} } } \section{Details}{ Methods \command{summary} and \command{dimensions} are defined for the \dQuote{parent}-class \command{\link[=RFsp-class]{RFsp}}. } \author{Alexander Malinowski, \martin} \seealso{ \code{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}}, which is for point locations in higher dimensional spaces, \code{\link{RFpointsDataFrame-class}} which is for one-dimensional arbitrary locations, \code{\link[=RFsp-class]{RFsp}} } \keyword{classes} \keyword{print} \keyword{hplot} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,length=100) f <- RFsimulate(model=RMgauss(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2) \dontshow{FinalizeExample()}} RandomFields/man/RMgencauchy.Rd0000644000176200001440000000671313437301604016100 0ustar liggesusers\name{RMgencauchy} \alias{RMgencauchy} \title{Generalized Cauchy Family Covariance Model} \description{ \command{\link{RMgencauchy}} is a stationary isotropic covariance model belonging to the generalized Cauchy family. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (1 + r^\alpha)^(-\beta/\alpha)}{C(r) = (1 + r^\alpha)^(-\beta/\alpha)} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2} and \eqn{\beta > 0}{\beta > 0}. See also \command{\link{RMcauchy}}. } \usage{ RMgencauchy(alpha, beta, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension.} \item{beta}{a numerical value; should be positive to provide a valid covariance function for a random field of any dimension.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model has a smoothness parameter \eqn{\alpha}{\alpha} and a parameter \eqn{\beta}{\beta} which determines the asymptotic power law. More precisely, this model admits simulating random fields where fractal dimension \emph{D} of the Gaussian sample and Hurst coefficient \emph{H} can be chosen independently (compare also with \command{\link{RMlgd}}): Here, we have \deqn{ D = d + 1 - \alpha/2, \alpha \in (0,2]}{ D = d + 1 - \alpha/2, 0 < \alpha \le 2} and \deqn{ H = 1 - \beta/2, \beta > 0.}{ H = 1 - \beta/2, \beta > 0.} I. e. the smaller \eqn{\beta}{\beta}, the longer the long-range dependence. The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly. Each covariance function of the Cauchy family is a normal scale mixture. Note that the Cauchy Family (see \command{\link{RMcauchy}}) is included in this family for the choice \eqn{\alpha = 2}{\alpha = 2} and \eqn{\beta = 2 \gamma}{\beta = 2 \gamma}. } \value{ \command{\link{RMgencauchy}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Covariance function \itemize{ % \item Gneiting, T. (2002) Compactly supported correlation % functions. \emph{J. Multivariate Anal.} \bold{83} 493--508. \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. } Tail correlation function (for \eqn{\alpha \in (0,1]}{0 < \alpha \le 1}) \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \me \seealso{ \command{\link{RMcauchy}}, \command{\link{RMcauchytbm}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgencauchy(alpha=1.5, beta=1.5, scale=0.3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMgengneiting.Rd0000644000176200001440000000714013437301604016423 0ustar liggesusers\name{RMgengneiting} \alias{RMgengneiting} \alias{RMwendland} \title{Gneiting-Wendland Covariance Models} \description{ \command{\link{RMgengneiting}} is a stationary isotropic covariance model family whose elements are specified by the two parameters \eqn{\kappa}{\kappa} and \eqn{\mu}{\mu} with \eqn{n}{n} being a non-negative integer and \eqn{\mu \ge \frac{d}{2}}{\mu \ge d/2} with \eqn{d}{d} denoting the dimension of the random field (the models can be used for any dimension). A corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points. For the case \eqn{\kappa = 0} the Gneiting-Wendland model equals the Askey model \command{\link{RMaskey}}, \deqn{C(r) = (1-r)^\beta 1_{[0,1]}(r),\qquad\beta = \mu +1/2 = \mu + 2\kappa + 1/2.}{ C(r) = (1-r)^\beta 1_{[0,1]}(r), \beta = \mu + 1/2 = \mu + 2\kappa + 1/2.} For \eqn{\kappa = 1} the Gneiting model is given by \deqn{C(r) = \left(1+\beta r \right)(1-r)^{\beta} 1_{[0,1]}(r), \qquad \beta = \mu +2\kappa+1/2.}{ C(r) = (1+\beta r)(1-r)^\beta 1_{[0,1]}(r), \beta = \mu + 2\kappa + 1/2.} If \eqn{\kappa = 2} \deqn{C(r) = \left(1 + \beta r + \frac{\beta^{2} - 1}{3}r^{2} \right)(1-r)^{\beta} 1_{[0,1]}(r), \qquad \beta = \mu+2\kappa+1/2.}{ C(r) = (1 + \beta r + (\beta^2 - 1) r^2 / 3) (1 - r)^\beta 1_{[0,1]}(r), \beta = \mu + 2\kappa + 1/2.} In the case \eqn{\kappa = 3} \deqn{ C(r) = \left( 1 + \beta r + \frac{(2\beta^{2}-3)}{5} r^{2}+ \frac{(\beta^2 - 4)\beta}{15} r^{3} \right)(1-r)^\beta 1_{[0,1]}(r), \qquad \beta = \mu+2\kappa + 1/2.}{ C(r) = (1 + \beta r + (2 \beta^2 - 3 )r^2 / 5 + (\beta^2 - 4) \beta r^3 / 15)(1-r)^\beta 1_{[0,1]}(r), \beta = \mu + 2\kappa + 1/2.} A special case of this model is \command{\link{RMgneiting}}. } \usage{ RMgengneiting(kappa, mu, var, scale, Aniso, proj) } \arguments{ \item{kappa}{\eqn{0,\ldots,3}{0,...,3}}; it chooses between the three different covariance models above. \item{mu}{\code{mu} has to be greater than or equal to \eqn{\frac{d}{2}}{d / 2} where \eqn{d} is the dimension of the random field.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This isotropic family of covariance functions is valid for any dimension of the random field. A special case of this family is \command{\link{RMgneiting}} (with \eqn{s = 1}{s = 1} there) for the choice \eqn{\kappa = 3, \mu = 3/2}{\kappa = 3, \mu = 3/2}. } \value{ \command{\link{RMgengneiting}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. (1999) Correlation functions for atmospherical data analysis. \emph{Q. J. Roy. Meteor. Soc} Part A \bold{125}, 2449-2464. \item Wendland, H. (2005) \emph{Scattered Data Approximation.} Cambridge Monogr. Appl. Comput. Math. } } \me \seealso{ \command{\link{RMaskey}}, \command{\link{RMbigneiting}}, \command{\link{RMgneiting}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgengneiting(kappa=1, mu=1.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) ## same models: model2 <- RMgengneiting(kappa=3, mu=1.5, scale= 1 / 0.301187465825) plot(RMgneiting(), model2=model2, type=c("p", "l"), pch=20) \dontshow{FinalizeExample()}} RandomFields/man/RMmatrix.Rd0000644000176200001440000001041313437301604015426 0ustar liggesusers\name{RMmatrix} \alias{RMmatrix} \alias{coregionalisation} \alias{coregionalization} %\alias{diag} %\alias{diag,RMmodel,missing,missing,missing-method} \title{Matrix operator} \description{ \command{\link{RMmatrix}} is a multivariate covariance model depending on one multivariate covariance model, or one or several univariate covariance models \eqn{C0,\ldots}{C0,\ldots}. The corresponding covariance function is given by \deqn{ C(h) = M \phi(h) M^t}{ C(h) = M phi(h) M^t} if a multivariate case is given. Otherwise it returns a matrix whose diagonal elements are filled with the univarate model(s) \code{C0}, \code{C1}, etc, and the offdiagonals are all zero. } \usage{ RMmatrix(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, M, vdim, var, scale, Aniso, proj) %\S4method{diag}{RMmodel,missing,missing,missing}(x,nrow,ncol,names) } \arguments{ \item{C0}{a k-variate covariance \command{\link{RMmodel}} or a univariate model or a list of models joined by \command{\link{c}} } \item{C1,C2,C3,C4,C5,C6,C7,C8,C9}{optional univariate models} \item{M}{a k times k matrix, which is multiplied from left and right to the given model; \eqn{M} may depend on the location, hence it is then a matrix-valued function and \eqn{C} will be non-stationary with \deqn{C(x, y) = M(x) \phi(x, y) M(y)^t}{ C(x, y) = M(x) phi(x, y) M(y)^t}} \item{vdim}{positive integer. This argument should be given if and only if a multivariate model is created from a single univariate model and \code{M} is not given. (In fact, if \code{M} is given, \code{vdim} must equal the number of columns of \code{M})} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} % \item{x}{an \link{R.c} list of \link{RMmodel}s} % \item{nrow,ncol,names}{ignored arguments} } \note{ \itemize{ % \item % The more intuitive code % \code{diag(c(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9))} % is identical to \code{RMmatrix(C0, C1, C2, C3, C4, C5, C6, C7, C8, % C9)}. Here \code{C0},..., \code{C9} must be univariate models. \item\command{RMmatrix} also allows variogram models are arguments. } } \value{\command{\link{RMmatrix}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}.} \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontrun{ ## first example: bivariate Linear Model of Coregionalisation x <- y <- seq(0, 10, 0.2) model1 <- RMmatrix(M = c(0.9, 0.43), RMwhittle(nu = 0.3)) + RMmatrix(M = c(0.6, 0.8), RMwhittle(nu = 2)) plot(model1) simu1 <- RFsimulate(RPdirect(model1), x, y) plot(simu1) ## second, equivalent way of defining the above model model2 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), c(RMwhittle(nu = 0.3), RMwhittle(nu = 2))) simu2 <- RFsimulate(RPdirect(model2), x, y) stopifnot(all.equal(as.array(simu1), as.array(simu2))) ## third, equivalent way of defining the above model model3 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), RMwhittle(nu = 0.3), RMwhittle(nu = 2)) simu3 <- RFsimulate(RPdirect(model3), x, y) stopifnot(all(as.array(simu3) == as.array(simu2))) } ## second example: bivariate, independent fractional Brownian motion ## on the real axis x <- seq(0, 10, 0.1) % to do: naechste Zeile RMmatrix durch diag ersetzen modelB <- RMmatrix(c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) ## see the Note above print(modelB) simuB <- RFsimulate(modelB, x) plot(simuB) ## third example: bivariate non-stationary field with exponential correlation ## function. The variance of the two components is given by the ## variogram of fractional Brownian motions. ## Note that the two components have correlation 1. x <- seq(0, 10, 0.1) modelC <- RMmatrix(RMexp(), M=c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) print(modelC) simuC <- RFsimulate(modelC, x, x, print=1) #print(as.vector(simuC)) plot(simuC) \dontshow{FinalizeExample()} }RandomFields/man/papers.SBS14.Rd0000644000176200001440000001241613437301604015755 0ustar liggesusers\name{SBS14} \alias{SBS14} %\alias{Papers} %\alias{schlather} %\alias{Schlather} \title{Systematic co-occurrence of tail correlation functions among max-stable processes } \description{ Here, the code of the paper on \sQuote{On some covariance models based on normal scale mixtures} is given. } \me \references{ \itemize{ \item Strokorb, K., Ballani, F. and Schlather, M. (2014) Systematic co-occurrence of tail correlation functions among max-stable processes. Work in progress. } } \examples{\dontshow{StartExample()} \dontshow{\dontrun{ RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again H <- c(0:9, LETTERS[1:6]) numbers <- rep(0:255, each=2) col <- c(paste("#0000", H[1 + ((0:255) / 16)], H[1 + ((0:255) \%\% 16)],sep=""), paste("#", H[1 + (numbers / 16)], H[1 + (numbers \%\% 16)], H[1 + (numbers / 16)], H[1 + (numbers \%\% 16)], "FF", sep="")) RFoptions(every=1000, xi=0) x <- seq(0, 5, 0.01) \dontshow{if(RFoptions()$internal$examples_red){warning("modified "); x <- seq(0, 5, 1)}} ## Figure 2 model <- RMfbm(alpha=1, var=4) ## not 8 as in the paper, since semi-variogram bm <- RMbrownresnick(model) # Fig. 2, Brown-Resnick z1 <- RFsimulate(RPbrownresnick(model), x, x) plot(z1, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_BRorig.pdf"); dev.print(device=jpeg, file="SBS_BRorig.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # Fig. 2, Monotone functions z2 <- RFsimulate(RPsmith(RMm2r(bm), xi=0), x, x, 0) plot(z2, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_mono.pdf"); dev.print(device=jpeg, file="SBS_mono.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # Fig. 2, balls z3 <- RFsimulate(RPsmith(RMm3b(bm)), x, x, 0, eps_zhou=0.1) plot(z3, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_ball.pdf"); dev.print(device=jpeg, file="SBS_ball.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # Fig. 2, z4 <- RFsimulate(RPsmith(RMmps(bm)), x, x, eps_zhou=0.1) plot(z4, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_poly.pdf"); dev.print(device=jpeg, file="SBS_poly.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ ## Figure 4 model <- RMexp(var=1.62) bm <- RMbrownresnick(model) }} \dontshow{\dontrun{ # Fig. 4, Brown-Resnick z5 <- RFsimulate(RPbrownresnick(model), x, x) plot(z5, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_BRexp.pdf"); dev.print(device=jpeg, file="SBS_BRexp.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # Fig. 4, extremal Gaussian z6 <- RFsimulate(RPschlather(bm), x, x) plot(z6, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_schlather.pdf"); dev.print(device=jpeg, file="SBS_schlather.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # Fig. 4, extremal binary z7 <- RFsimulate(RPschlather(RPbernoulli(bm)), x, x) plot(z7, col=col) }} \dontshow{\dontrun{ dev.copy2pdf(file="SBS_binary.pdf"); dev.print(device=jpeg, file="SBS_binary.jpg", height=1000, width=1000, quality=100) }} \dontshow{\dontrun{ # gamma_strokorb = 2 gamma_RandomFields # -> ecf = erfc(sqrt(gamma_RandomFields / 4)) strokorb <- function(t) { ( 1 + 4 * t ) / ((2 * pi)^1.5 * (2 * t)^2.5) * exp(- 2 * t) } density <- function(x, u) { z <- apply(abs(x - u), 2, max) # Print(z, u, x) return(strokorb(min(z))) } RFoptions(xi=0) model <- RMfbm(var=4, alpha=1) ## not 8 as in the paper as ## SEMI-variograms are used in RandomFields, not variograms ## as in several theoretical papers. sm <- RMm2r(RMbrownresnick(model)) x <- seq(0, 10, 0.02) z <- RFsimulate(RPsmith(RMm2r(RMbrownresnick(model)), xi=0), x, x, 0, n=1) H <- c(0:9, LETTERS[1:6]) numbers <- rep(0:255, each=2) col <- c(paste("#0000", H[1 + ((0:255) / 16)], H[1 + ((0:255) %% 16)], sep=""), paste("#", H[1 + (numbers / 16)], H[1 + (numbers %% 16)], H[1 + (numbers / 16)], H[1 + (numbers %% 16)], "FF", sep="") ) plot(z, type="p", pch=20, cex=0.4, col=col) # dev.copy2pdf(file="strokorb.pdf") readline() y <- as.double(as.matrix(z@data)) Print(range(y)) hist(y, 200, freq=FALSE) a <- seq(-4, 10, 0.1) lines(a, exp(-a) * exp(-exp(-a))) ############# test system.time( z <- RFsimulate(RPsmith(RMm2r(RMbrownresnick(model)), xi=0), seq(0, len=400, by=0.02), seq(0, len=400, by=0.02), 0, n=1, spConform=FALSE, every=0) ) ### ### Hintergrundbild z <- RFsimulate(RPsmith(RMm2r(RMbrownresnick(model)), xi=0), seq(0, 1920/100, 0.02), seq(0, 1280/100, 0.02), 0, n=1, spConform=FALSE, every=0) H <- c(0:9, LETTERS[1:6]) numbers <- rep(0:240, each=1) col <- c(paste("#0000", H[1 + ((0:255) / 16)], H[1 + ((0:255) %% 16)], sep=""), paste("#", H[1 + (numbers / 16)], H[1 + (numbers %% 16)], H[1 + (numbers / 16)], H[1 + (numbers %% 16)], "FF", sep="") ) png(filename="~/Pictures/strokorb.png", width=1920, height=1280)#1930,1290 par(mar=rep(0,4)) image(z[,,1], col=col) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RFfractaldim.Rd0000644000176200001440000001354713437301604016234 0ustar liggesusers\name{RFfractaldim} \alias{RFfractaldim} \title{RFfractaldimension} \description{ The function estimates the fractal dimension of a process } \usage{ RFfractaldim(x, y = NULL, z = NULL, data, grid, bin=NULL, vario.n=5, sort=TRUE, fft.m = c(65, 86), ## in % of range of l.lambda fft.max.length=Inf,% fft.max.regr=150000, fft.shift = 50, # in %; 50:WOSA; 100: no overlapping method=c("variogram", "fft"), % "box", "range", mode = if (interactive ()) c("plot", "interactive") else "nographics", %ok pch=16, cex=0.2, cex.main=0.85, printlevel = RFoptions()$basic$printlevel, height=3.5, ...) } \arguments{ \item{x}{\argX If \code{x} is not given and \code{data} is not an \pkg{sp} object, a grid with unit grid length is assumed} \item{y,z}{\argYz} \item{data}{the values measured; it can also be an \pkg{sp} object} \item{grid}{\argGrid} \item{bin}{sequence of bin boundaries for the empirical variogram} \item{vario.n}{first \code{vario.n} values of the empirical variogram are used for the regression fit that are not \code{NA}.} \item{sort}{If \code{TRUE} then the coordinates are permuted such that the largest grid length is in \code{x}-direction; this is of interest for algorithms that slice higher dimensional fields into one-dimensional sections.} % \item{box.sequ}{sequence of box length for which the number of % covering boxes is calculated.} % \item{box.enlarge.y}{The grid of coordinates is always standardised to % the marginal interval \eqn{[0, 1]}. The \code{data} are standardised % to the interval \eqn{[0, \code{box.enlarge.y}]}.} % \item{range.sequ}{sequence of box lengths; for each box length and a % covering set of boxes the sum of the ranges for the values in each % box is calculated.} \item{fft.m}{numeric vector of two components; interval of frequencies for which the regression should be calculated; the interval is given in percent of the range of the frequencies in log scale.} \item{fft.max.length}{The first dimension of the data is cut into pieces of length \code{fft.max.length}. For each piece the FFT is calculated and then the average for all pieces is taken. The pieces may overlap, see the argument \code{fft.shift}.} \item{fft.max.regr}{If the \code{fft.m} is too large, parts of the regression fit will take a very long time. Therefore, the regression fit is calculated only if the number points given by \code{fft.m} is less than \code{fft.max.regr}. } \item{fft.shift}{This argument is given in percent [of \code{fft.max.length}] and defines the overlap of the pieces defined by \code{fft.max.length}. If \code{fft.shift=50} the WOSA estimator is given; if \code{fft.shift=100} no overlap exists.} \item{method}{ list of implemented methods to calculate the fractal dimension; see Details } \item{mode}{character. A vector with components \code{'nographics'}, \code{'plot'} or \code{'interactive'}: \describe{ \item{\code{'nographics'}}{no graphical output} \item{\code{'plot'}}{the regression line is plotted} \item{\code{'interactive'}}{the regression domain can be chosen interactively} } Usually only one mode is given. Two modes may make sense in the combination \code{c("plot", "interactive")}. In this case, all the results are plotted first, and then the interactive mode is called. In the interactive mode, the regression domain is chosen by two mouse clicks with the left mouse; a right mouse click leaves the plot. } \item{pch}{vector or scalar; sign by which data are plotted.} \item{cex}{vector or scalar; size of \code{pch}.} \item{cex.main}{The size of the title in the regression plots.} \item{printlevel}{integer. If \code{printlevel} is 0 nothing is printed. If \code{printlevel=1} error messages are printed. If \code{printlevel=2} warnings and the regression results are given. If \code{printlevel>2} tracing information is given. } \item{height}{height of the graphics window} \item{...}{graphical arguments} } \details{ The function calculates the fractal dimension by various methods: \itemize{ \item variogram method % \item box counting % \item min / max method \item Fourier transform } } \value{ The function returns a list with elements \code{vario}, %\code{box}, \code{range}, \code{fft} corresponding to the 2 methods given in the Details. Each of the elements is itself a list that contains the following elements. \item{x}{the x-coordinates used for the regression fit} \item{y}{the y-coordinates used for the regression fit} \item{regr}{the return list of the \command{\link[stats]{lm}}.} \item{sm}{smoothed curve through the (x,y) points} \item{x.u}{\code{NULL} or the restricted x-coordinates given by the user in the interactive plot} \item{y.u}{\code{NULL} or y-coordinates according to \code{x.u}} \item{regr.u}{\code{NULL} or the return list of \command{\link[stats]{lm}} for \code{x.u} and \code{y.u}} \item{D}{the fractal dimension} \item{D.u}{\code{NULL} or the fractal dimension corresponding to the user's regression line} } \references{ % Overviews: % \itemize{ % \item{-}{-} % } variogram method \itemize{ \item Constantine, A.G. and Hall, P. (1994) Characterizing surface smoothness via estimation of effective fractal dimension. \emph{J. R. Statist. Soc. Ser. B} \bold{56}, 97-113. } % box counting % \itemize{ % \item{-}{-} % } % min/max % \itemize{ % \item{-}{-} % } fft \itemize{ \item Chan, Hall and Poskitt (1995) } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFhurst}} } \keyword{ spatial }%-- one or more ... \examples{\dontshow{StartExample(reduced=50)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.001) z <- RFsimulate(RMexp(), x) RFfractaldim(data=z) \dontshow{FinalizeExample()}}RandomFields/man/internal.Rd0000644000176200001440000001076613437301604015512 0ustar liggesusers\name{Internal functions} \alias{rfGenerateModels} \alias{rfGenerateConstants} \alias{rfGenerateTest} \alias{rfGenerateMaths} \alias{checkExamples} \alias{StartExample} \alias{FinalizeExample} \alias{Dependencies}\alias{ScreenDevice} \alias{plotWithCircles} \alias{showManpages} \alias{RM_DEFAULT} \alias{maintainers.machine} \title{Internal functions} \description{ These functions are internal and should not be used. } \usage{ rfGenerateModels(package = "RandomFields", assigning, RFpath ="~/svn/RandomFields/RandomFields", RMmodels.file=paste(RFpath, "R/RMmodels.R", sep="/"), PL = RFoptions()$basic$printlevel) rfGenerateConstants(package="RandomFields", aux.package = "RandomFieldsUtils", RFpath = paste0("~/svn/",package, "/", package), RCauto.file = paste(RFpath, "R/aaa_auto.R", sep="/"), header.source = c(if (length(aux.package) > 0) paste0("../../", aux.package,"/", aux.package, "/src/Auto", aux.package, ".h"), paste0("src/Auto",package,".h")), c.source = paste0("src/Auto", package, ".cc")) rfGenerateTest(package = "RandomFields", files = NULL, RFpath = paste0("~/svn/", package, "/", package)) rfGenerateMaths(package = "RandomFields", files = "/usr/include/tgmath.h", do.cfile = FALSE, ## copy also in ../private/lit Cfile = "QMath", Rfile = "RQmodels", RFpath = paste0("~/svn/",package,"/", package)) checkExamples(exclude = NULL, include=1:length(.fct.list), ask=FALSE, echo=TRUE, halt=FALSE, ignore.all = FALSE, path=package, package = "RandomFields", read.rd.files=TRUE, local = TRUE, libpath = NULL, single.runs = FALSE) ScreenDevice(height, width) FinalizeExample() StartExample(reduced = TRUE, save.seed = TRUE) %Dependencies(pkgs = all.pkgs, dir = "Dependencies", % install = FALSE, check=TRUE, reverse=FALSE, package = % "RandomFields") showManpages(path="/home/schlather/svn/RandomFields/RandomFields/man") plotWithCircles(data, factor=1.0, xlim=range(data[,1])+c(-maxr,maxr), ylim=range(data[,2])+c(-maxr,maxr), col=1, fill=0, ...) maintainers.machine() } \arguments{ \item{package,assigning, RFpath, RMmodels.file, PL}{internal} \item{aux.package,RCauto.file,header.source,c.source}{internal} \item{files}{internal} \item{Cfile, Rfile, do.cfile }{internal} \item{exclude, include, ask, echo, halt, ignore.all, path, read.rd.files, libpath, single.runs }{internal; ignore.all refers to the \sQuote{all} export statement in the namespace -- whether this should be ignored. If \code{read.rf.files} is \code{TRUE} or a path to the Rd files, then the man pages are analysed to get all examples; \code{ignore.all} is then ignored. If \code{FALSE} only examples of functions (which are searched in the environments) are run. } % \item{pkgs, dir,install, check, reverse}{internal} \item{height,width}{window sizes} \item{data, factor, xlim, ylim, col, fill, ...}{internal} \item{reduced, save.seed, local}{internal} % \item{REGISTER, COVREGISTER, RELAX}{internal} } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## internal functions: no examples given \dontshow{\dontrun{ ## OK ## check own examples checkExamples(ignore.all=TRUE, halt=!TRUE) ### Check the examples of the other packages: dep.packages <- c( #"DSpat","lgcp", "constrainedKriging", "MarkedPointProcess", "Geneland", "glmmBUGS", "ProbForecastGOP","geoR", "CompRandFld", ## RFsim does not work in version 2.1.18 "fractaldim", "rpanel", "spatstat") #for (i in dep.packages) library(i, character.only=TRUE) #for (i in dep.packages) install.packages(i) not.working <- list() for (.i in 1:length(dep.packages)) { not.working[[.i]] <- checkExamples(path=paste("~/TMP/dep.packages", dep.packages[.i], sep="/"), package=dep.packages[.i]) Print(.i, not.working); repeat{ if (readline()=="e") break} } Print(not.working) }} # for (i in dep.packages) cat(maintainer(i), "\n") \dontshow{FinalizeExample()}} RandomFields/man/RMschlather.Rd0000644000176200001440000000376013437301604016106 0ustar liggesusers\name{RMschlather} \alias{RMschlather} \title{Covariance Model for binary field based on Gaussian field} \description{ \command{RMschlather} gives the tail correlation function of the extremal Gaussian process, i.e. \deqn{C(h) = 1 - \sqrt{ (1-\phi(h)/\phi(0)) / 2 }} where \eqn{\phi} is the covariance of a stationary Gaussian field. } \usage{ RMschlather(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model yields the tail correlation function of the field that is returned by \command{\link{RPschlather}}. } \value{ \command{\link{RMschlather}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RPschlather}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## This example considers an extremal Gaussian random field ## with Gneiting's correlation function. ## first consider the covariance model and its corresponding tail ## correlation function model <- RMgneiting() plot(model, model.tail.corr.fct=RMschlather(model), xlim=c(0, 5)) ## the extremal Gaussian field with the above underlying ## correlation function that has the above tail correlation function x <- seq(0, 10, 0.1) z <- RFsimulate(RPschlather(model), x) plot(z) ## Note that in RFsimulate R-P-schlather was called, not R-M-schlather. ## The following lines give a Gaussian random field with correlation ## function equal to the above tail correlation function. z <- RFsimulate(RMschlather(model), x) plot(z) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RFempVariog-class.Rd0000644000176200001440000001364213437301604017156 0ustar liggesusers\name{RFempVariog-class} \docType{class} \alias{RFempVariog-class} \alias{coerce,RFempVariog,list-method} \alias{show,RFempVariog-method} \alias{persp,RFempVariog-method} \alias{print,RFempVariog-method} \alias{summary,RFempVariog-method} \alias{print.RF_empVariog} \alias{summary.RF_empVariog} \alias{plot,RFempVariog,missing-method} \alias{RFplotEmpVariogram} \title{Class \code{RFempVariog}} \description{Class for RandomFields' representation of empirical variograms } %\section{Creating Objects}{ % Objects are created by calling a function of class % \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} %} \usage{ RFplotEmpVariogram(x, model = NULL, nmax.phi = NA, nmax.theta = NA, nmax.T = NA, plot.nbin = TRUE, plot.sd=FALSE, method = "ml", variogram=TRUE, boundaries = TRUE, ...) \S4method{plot}{RFempVariog,missing}(x, y, ...) \S4method{persp}{RFempVariog}(x, ...) } \arguments{ \item{x}{object of class \command{\link[=RFempVariog-class]{RFempVariog}} } \item{y}{unused} \item{model}{\argModel. Or a list of such models. Tit gives the covariance or variogram models that are to be plotted into the same plot as the empirical variogram (and the fitted models)} \item{nmax.phi}{even integer; only for \code{class(x)=="RFempVariog"}; the number of bins of angle phi that are to be plotted}. \item{nmax.theta}{integer; only for \code{class(x)=="RFempVariog"}; the number of bins of angle theta that are to be plotted} \item{nmax.T}{integer; only for \code{class(x)=="RFempVariog"}; the maximal number of different time bins that are to be plotted} \item{plot.nbin}{logical; only for \code{class(x)=="RFempVariog"}; indicates whether the number of pairs per bin are to be plotted} \item{plot.sd}{logical; only for \code{class(x)=="RFempVariog"}; indicates whether the calculated standard deviation (\code{x@sd}) is to be plotted (in form of arrows of length +-1*sd)} \item{method}{character. Currently restricted to \code{"ml"} for maximum-likelihood method. } \item{variogram}{logical; This argument should currently not be set by the user. If \code{TRUE} then the empirical variogram is plotted, else an estimate for the covariance function.} \item{boundaries}{logical; only for \code{class(x)=="RFempVariog"} and the anisotropic case where \code{model} is given. As the empirical variogram is calculated on a sector of angles, no exact variogram curve corresponds to the mean values in this sector. If \code{boundaries=TRUE} the values of the variogram on the sector boundaries are plotted. If \code{FALSE} some kind of mean model values are plotted. Neither the boundaries may contain the values of empirical variogram nor does the mean values need to be close the empirical variogram. } \item{...}{arguments to be passed to methods; mainly graphical arguments. %see Details. } } \section{Slots}{ \describe{ \item{\code{centers}:}{the bin centres of the spatial distances} \item{\code{empirical}:}{value of the empirical variogram} \item{\code{var}:}{ the empirical (overall) variance in the data } \item{\code{sd}:}{standard deviation of the variogram cloud within each bin} \item{\code{n.bin}:}{number of bins} \item{\code{phi.centers}:}{centres of the bins with respect to the (first) angle (for anisotropic empirical variograms only)} \item{\code{theta.centers}:}{centres of the bins with respect to the second angle (for anisotropic empirical variograms in 3D only)} \item{\code{T}:}{the bin centres of the time axis} \item{\code{vdim}:}{the multivariate dimension} \item{\code{coordunits}:}{string giving the units of the coordinates, see also option \code{coordunits} of \command{\link{RFoptions}}. } \item{\code{varunits}:}{string giving the units of the variables, see also option \code{varunits} of \command{\link{RFoptions}}. } \item{\code{call}:}{language object; the function call by which the object was generated} \item{\code{method}:}{integer; variogram (0), covariance (2), madogram (4) } } } \section{Methods}{ \describe{ \item{plot}{\code{signature(x = "RFempVariog")}: gives a plot of the empirical variogram, for more details see \command{\link{plot-method}}.} \item{plot}{\code{signature(x = "RFempVariog", y = "missing")}}{Gives nice plots of the empirical variogram; handles binning in up to three space-dimensions and a time-dimension, where the empirical variogram is plotted along lines which are directed according to the angle-centers given in \code{x@phi.centers} and \code{x@theta.centers}; arbitrary theoretical model curves can be added to the plot by using the argument \code{model}. If no bins are given, i.e. (\code{x@bin=NULL}), \command{\link[graphics]{image}}-plots are generated.} \item{as}{\code{signature(x = "RFempVariog")}: converts into other formats, only implemented for target class \code{\link[methods:list-class]{list}}.} \item{show}{\code{signature(x = "RFfit")}: returns the structure of \code{x}} \item{persp}{\code{signature(obj = "RFempVariog")}: generates nice \command{\link[graphics]{persp}} plots } \item{print}{\code{signature(x = "RFfit")}: identical with \command{show}-method} \item{summary}{provides a summary} } } \section{Details}{ \command{print} returns also an invisible list that is convenient to access. } \author{Alexander Malinowski, \martin} \seealso{ \command{\link{RFvariogram}}, \command{\link{plot-method}} } \examples{\dontshow{StartExample()} # see 'RFvariogram' \dontshow{FinalizeExample()}} \keyword{classes} \keyword{print} \keyword{hplot} RandomFields/man/RFgetMethodNames.Rd0000644000176200001440000002512313437301604017023 0ustar liggesusers\name{RFgetMethodNames} \alias{RFgetMethodNames} \title{Simulation Techniques} \description{ \command{\link{RFgetMethodNames}} prints and returns a list of currently implemented methods for simulating Gaussian random fields and max stable random fields } \usage{ RFgetMethodNames() } \value{ an invisible string vector of the Gaussian methods. } \details{ By default, \command{\link{RFsimulate}} automatically chooses an appropriate method for simulation. The method can also be set explicitly by the user via \command{\link{RFoptions}}, in particular by passing \code{gauss.method=_a valid method string_} as an additional argument to \command{\link{RFsimulate}} or by globally changing the options via \code{\link{RFoptions}(gauss.method=_a valid method string_)}. The following methods are available: \itemize{ \item (random spatial) Averages\cr -- details soon \item Boolean functions.\cr See marked point processes. \item \code{circulant embedding}. \cr Introduced by Dietrich & Newsam (1993) and Wood and Chan (1994). Circulant embedding is a fast simulation method based on Fourier transformations. It is garantueed to be an exact method for covariance functions with finite support, e.g. the spherical model. See also \code{cutoff embedding} and \code{intrinsic embedding} for variants of the method. \item \code{cutoff embedding}. \cr Modified circulant embedding method so that exact simulation is guaranteed for further covariance models, e.g. the whittle matern model. In fact, the circulant embedding is called with the cutoff hypermodel, see \command{\link{RMmodel}}, and \eqn{A=B} there. \code{cutoff embedding} halfens the maximum number of elements models used to define the covariance function of interest (from 10 to 5). Here, multiplicative models are not allowed (yet). \item \code{direct matrix decomposition}.\cr This method is based on the well-known method for simulating any multivariate Gaussian distribution, using the square root of the covariance matrix. The method is pretty slow and limited to about 8000 points, i.e. a 20x20x20 grid in three dimensions. This implementation can use the Cholesky decomposition and the singular value decomposition. It allows for arbitrary points and arbitrary grids. \item \code{hyperplane method}.\cr The method is based on a tessellation of the space by hyperplanes. Each cell takes a spatially constant value of an i.i.d. random variables. The superposition of several such random fields yields approximatively a Gaussian random field. \item \code{intrinsic embedding}. \cr Modified circulant embedding so that exact simulation is guaranteed for further \emph{variogram} models, e.g. the fractal brownian one. Note that the simulated random field is always \emph{non-stationary}. In fact, the circulant embedding is called with the Stein hypermodel, see \command{\link{RMmodel}}, and \eqn{A=B} there. Here, multiplicative models are not allowed (yet). \item Marked point processes.\cr Some methods are based on marked point process \eqn{\Pi=\bigcup [x_i,m_i]}{P = ([x_1,m_1], [x_2,m_2], ...)} where the marks \eqn{m_i}{m_i} are deterministic or i.i.d. random functions on \eqn{R^d}{R^d}. \itemize{ \item \code{add.MPP} (Random coins).\cr Here the functions are elements of the intersection \eqn{L_1 \cap L_2}{(L1 cap L2)} of the Hilbert spaces \eqn{L_1}{L1} and \eqn{L_2}{L2}. A random field Z is obtained by adding the marks: \deqn{ Z(\cdot) = \sum_{[x_i,m_i] \in \Pi} m_i(\cdot - x_i)}{ Z(.) = sum_i m_i( . - x_i)} In this package, only stationary Poisson point fields are allowed as underlying unmarked point processes. Thus, if the marks \eqn{m_i}{m_i} are all indicator functions, we obtain a Poisson random field. If the intensity of the Poisson process is high we obtain an approximative Gaussian random field by the central limit theorem - this is the \code{add.mpp} method. \item \code{max.MPP} (Boolean functions).\cr If the random functions are multiplied by suitable, independent random values, and then the maximum is taken, a max-stable random field with unit Frechet margins is obtained - this is the \code{max.mpp} method. } \item \code{nugget}.\cr The method allows for generating a random field of independent Gaussian random variables. This method is called automatically if the nugget effect is positive except the method \code{"circulant embedding"} or \code{"direct"} has been explicitly chosen. The method has been extended to zonal anisotropies, see also argument \code{nugget.tol} in \command{\link{RFoptions}}. \item \code{particular} method\cr -- details missing -- \item Random coins.\cr See marked point processes. \item \code{sequential} This method is programmed for spatio-temporal models where the field is modelled sequentially in the time direction conditioned on the previous \eqn{k} instances. For \eqn{k=5} the method has its limits for about 1000 spatial points. It is an approximative method. The larger \eqn{k} the better. It also works for certain grids where the last dimension should contain the highest number of grid points. \item \code{spectral TBM} (Spectral turning bands).\cr The principle of \code{spectral TBM} does not differ from the other turning bands methods. However, line simulations are performed by a spectral technique (Mantoglou and Wilson, 1982). The standard method allows for the simulation of 2-dimensional random fields defined on arbitrary points or arbitrary grids. Here, a realisation is given as the cosine with random amplitude and random phase. \item \code{TBM2}, \code{TBM3} (Turning bands methods; turning layers).\cr It is generally difficult to use the turning bands method (\code{TBM2}) directly in the 2-dimensional space. Instead, 2-dimensional random fields are frequently obtained by simulating a 3-dimensional random field (using \code{TBM3}) and taking a 2-dimensional cross-section. TBM3 allows for multiplicative models; in case of anisotropy the anisotropy matrices must be multiples of the first matrix or the anisotropy matrix consists of a time component only (i.e. all components are zero except the very last one).\cr \code{TBM2} and \code{TBM3} allow for arbitrary points, and arbitrary grids (arbitrary number of points in each direction, arbitrary grid length for each direction). \bold{Note:} Both the precision and the simulation time depend heavily on \code{TBM*.linesimustep} and \code{TBM*.linesimufactor} that can be set by \command{\link{RFoptions}}. For covariance models with larger values of the scale parameter, \code{TBM*.linesimufactor=2} is too small. The turning layers are used for the simulations with time component. Here, if the model is a multiplicative covariance function then the product may contain matrices with pure time component. All the other matrices must be equal up to a factor and the temporal part of the anisotropy matrix (right column) may contain only zeros, except the very last entry. } } \note{Most methods possess additional arguments, see \code{\link{RFoptions}()} that control the precision of the result. The default arguments are chosen such that the simulations are fine for many models and their parameters. The example in \code{\link{RFvariogram}()} shows a way of checking the precision. } \references{ Gneiting, T. and Schlather, M. (2004) Statistical modeling with covariance functions. \emph{In preparation.} Lantuejoul, Ch. (2002) \emph{Geostatistical simulation.} \bold{New York:} Springer. Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. Original work: \itemize{ \item Circulant embedding: Chan, G. and Wood, A.T.A. (1997) An algorithm for simulating stationary Gaussian random fields. \emph{J. R. Stat. Soc., Ser. C} \bold{46}, 171-181. Dietrich, C.R. and Newsam, G.N. (1993) A fast and exact method for multidimensional Gaussian stochastic simulations. \emph{Water Resour. Res.} \bold{29}, 2861-2869. Dietrich, C.R. and Newsam, G.N. (1996) A fast and exact method for multidimensional {G}aussian stochastic simulations: Extensions to realizations conditioned on direct and indirect measurement \emph{Water Resour. Res.} \bold{32}, 1643-1652. Wood, A.T.A. and Chan, G. (1994) Simulation of stationary Gaussian processes in \eqn{[0,1]^d}{[0,1]^d} \emph{J. Comput. Graph. Stat.} \bold{3}, 409-432. The code used in \cite{RandomFields} is based on Dietrich and Newsam (1996). \item Intrinsic embedding and Cutoff embedding: Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599. Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M. and Jiang, Y. (2005) Fast and Exact Simulation of Large Gaussian Lattice Systems in \eqn{R^2}: Exploring the Limits \emph{J. Comput. Graph. Statist.} Submitted. \item Markov Gaussian Random Field: Rue, H. (2001) Fast sampling of Gaussian Markov random fields. \emph{J. R. Statist. Soc., Ser. B}, \bold{63} (2), 325-338. Rue, H., Held, L. (2005) \emph{Gaussian Markov Random Fields: Theory and Applications.} Monographs on Statistics and Applied Probability, no \bold{104}, Chapman \& Hall. \item Turning bands method (TBM), turning layers: Dietrich, C.R. (1995) A simple and efficient space domain implementation of the turning bands method. \emph{Water Resour. Res.} \bold{31}, 147-156. Mantoglou, A. and Wilson, J.L. (1982) The turning bands method for simulation of random fields using line generation by a spectral method. \emph{Water. Resour. Res.} \bold{18}, 1379-1394. Matheron, G. (1973) The intrinsic random functions and their applications. \emph{Adv. Appl. Probab.} \bold{5}, 439-468. Schlather, M. (2004) Turning layers: A space-time extension of turning bands. \emph{Submitted} \item Random coins: Matheron, G. (1967) \emph{Elements pour une Theorie des Milieux Poreux}. Paris: Masson. } } \section{Automatic selection algorithm}{ --- details coming soon --- } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \link[=RandomFields-package]{RandomFields}. } \keyword{spatial} % to do: max-stable beschreiben?? \examples{\dontshow{StartExample()} RFgetMethodNames() \dontshow{FinalizeExample()} } RandomFields/man/RFformulaAdvanced.Rd0000644000176200001440000000633613437301604017217 0ustar liggesusers\name{RFformulaAdvanced} \alias{RFformulaAdvanced} \note{ \code{NaN}, in contrast to \code{NA}, signifies a unknown parameter that can be calculated from other (unknown) parameters. } \title{Advanced RFformula} \description{Here examples for much more advanced formula are given} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################# ### the following definitions are needed in all the examples ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) ################################################################# ### Example 1: simple example ### ################################################################# ## the following to definitions of a model and call of RFsimulate ## give the same result: model <- RMexp(var=V, scale=S) + M z1 <- RFsimulate(model = model, x=x, y=y) plot(z1) model <- ~ M + RMexp(var=var, scale=sc) p <- list(var=V, sc=S, M=M) z2 <- RFsimulate(model = model,x=x, y=y, param=p) plot(z2) ################################################################# ### Example 2: formulae within the parameter list ### ################################################################# ## free parameters (above 'var' and 'sc') can be used ## even within the definition of the list of 'param'eters model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) ## ordering does not matter! z1 <- RFsimulate(model, x, y, params=p) plot(z1) RFgetModel(RFsimulate) ## note that V * abs(cos(S) equals 9.553365 ## so the above is equivalent to model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=var * abs(cos(sc))) z2 <- RFsimulate(model, x, y, params=list(var=V, sc=S)) plot(z2) ################################################################# ### Example 3: formulae for fitting (i.e. including NAs) ### ################################################################# ## first generate some data model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) z <- RFsimulate(model, x, y, params=p, n=10) ## estimate the parameters p.fit <- list(sc = NA, var=NA, nugg=NA) print(f <- RFfit(model, data=z, params=p.fit)) ## estimation with a given boundaries for the scale p.fit <- list(sc = NA, var=NA, nugg=NA) lower <- list(sc=0.01) upper <- list(sc=0.02) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper)) ################################################################# ### Example 4 (cont'd Ex 3): formulae with dummy variables ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) model <- ~ RMexp(sc=sc1, var=var) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) ## introduces dummy variable 'u' p.fit <- list(sc1 = NA, var=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper )) \dontshow{FinalizeExample()} } RandomFields/man/papers.GSPSJ06.Rd0000644000176200001440000000414513437301604016215 0ustar liggesusers\name{GSPSJ06} \alias{GSPSJ06} %\alias{Papers} %\alias{schlather} %\alias{Schlather} \title{Fast and Exact Simulation of Large Gaussian Lattice Systems in R2} \description{ Here, the code of the paper on \sQuote{Fast and Exact Simulation of Large Gaussian Lattice Systems in R2} is given. } \me \references{ \itemize{ \item Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M., Jiang, Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in R2: Exploring the Limits. \emph{J. Comput. Graph. Stat.}, \bold{15}, 483-501. } % Schlather, M. (2001) Simulation of stationary and isotropic random % fields. \emph{R-News} \bold{1} (2), 18-20. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Figure 1 (pretty time consuming) stabletest <- function(alpha, theta, size=512) { RFoptions(trials=1, tolIm = 1e-8, tolRe=0, force = FALSE, useprimes=TRUE, strategy=0, skipchecks=!FALSE, storing=TRUE) model <- RMcutoff(diameter=theta, a=1, RMstable(alpha=alpha)) RFcov(dist=0, model=model, dim=2, seed=0) r <- RFgetModelInfo(modelname="RMcutoff", level=3)$storage$R_theor x <- seq(0, r, by= r / (size - 1)) * theta err <- try(RFsimulate(x, x, model=RPcirculant(model), n=0)) return(if (class(err) == "try-error") NA else r) } alphas <- seq(1.52, 2.0, 0.02) thetas <- seq(0.05, 3.5, 0.05) \dontshow{if (RFoptions()$internal$examples_reduced) { warning("reduced size of alphas and thetas") alphas <- seq(1.52, 2.0, 0.5) thetas <- seq(0.1, 3.5, 2) } } m <- matrix(NA, nrow=length(thetas), ncol=length(alphas)) for (it in 1:length(thetas)) { theta <- thetas[it] for (ia in 1:length(alphas)) { alpha <- alphas[ia] cat("alpha=", alpha, "theta=", theta,"\n") m[it, ia] <- stabletest(alpha=alpha, theta=theta) if (is.na(m[it, ia])) break } if (any(is.finite(m))) image(thetas, alphas, m, col=rainbow(100)) } \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/ca20.Rd0000644000176200001440000000504213616114720014412 0ustar liggesusers\name{ca20} \alias{ca20} \alias{ca20.df} \docType{data} \encoding{latin1} \title{Calcium content in soil samples} \usage{data(ca20)} \description{ This data set contains the calcium content measured in soil samples taken from the 0-20cm layer at 178 locations within a certain study area divided in three sub-areas. The elevation at each location was also recorded. The first region is typically flooded during the rain season and not used as an experimental area. The calcium levels would represent the natural content in the region. The second region has received fertilisers a while ago and is typically occupied by rice fields. The third region has received fertilisers recently and is frequently used as an experimental area. } \format{ The object \code{ca20} belongs to the class \code{geodata} and is a list with the following elements: \describe{ \item{\code{coords}}{a matrix with the coordinates of the soil samples. } \item{\code{data}}{calcium content measured in \eqn{mmol_c/dm^3}. } \item{\code{covariate}}{a data-frame with the covariates \describe{ \item{\code{altitude}}{a vector with the elevation of each sampling location, in meters (\eqn{m}).} \item{\code{area}}{a factor indicating the sub area to which the locations belongs.} } } \item{\code{borders}}{a matrix with the coordinates defining the borders of the area. } \item{\code{reg1}}{a matrix with the coordinates of the limits of the sub-area 1. } \item{\code{reg1}}{a matrix with the coordinates of the limits of the sub-area 2. } \item{\code{reg1}}{a matrix with the coordinates of the limits of the sub-area 3. } } } \source{ The data was collected by researchers from PESAGRO and EMBRAPA-Solos, Rio de Janeiro, Brasil and provided by Dra. Maria Cristina Neves de Oliveira. Capeche, C.L.; Macedo, J.R.; Manzatto, H.R.H.; Silva, E.F. (1997) Caracterizao pedolgica da fazenda Angra - PESAGRO/RIO - Estao experimental de Campos (RJ). (compact disc). In: Congresso BRASILEIRO de Cincia do Solo. 26., Informao, globalizao, uso do solo; Rio de Janeiro, 1997. trabalhos. Rio de Janeiro: Embrapa/SBCS. } \references{ Oliveira, M.C.N. (2003) \emph{Mtodos de estimao de parmetros em modelos geoestatsticos com diferentes estruturas de covarincias: uma aplicao ao teor de clcio no solo.} Tese de Doutorado, ESALQ/USP/Brasil. Further information on the package \pkg{geoR} can be found at:\cr \url{http://www.leg.ufpr.br/geoR}. } \keyword{datasets} RandomFields/man/RFoldstyle.Rd0000644000176200001440000000177413437301604015764 0ustar liggesusers\name{RFoldstyle} \alias{RFoldstyle} \title{RFoldstyle} \description{ This function is written only for package writers who have based their code on RandomFields version 2. It avoids warnings if the old style is used, and sets \code{spConform = FALSE}. } \usage{ RFoldstyle(old=TRUE) } \arguments{ \item{old}{logical} } \value{ \code{NULL} } %\note{ % see for partial documentation of the former % functions. Note that the documentation is not maintained. %} \seealso{ See \sQuote{\href{../doc/version.pdf}{version2}} for details on the commands of version 2. } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE) RFoldstyle() GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE) \dontshow{RFoldstyle(FALSE)} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMiaco.Rd0000644000176200001440000000256113437301604015042 0ustar liggesusers\name{RMiaco} \alias{RMiaco} \title{Iaco-Cesare model} \description{ The space-time covariance function is \deqn{ C(r,t) = (1.0 + r^\nu + t^\lambda)^\delta } } \usage{ RMiaco(nu, lambda, delta, var, scale, Aniso, proj) } \arguments{ \item{nu,lambda}{number in \eqn{(0,2]}} \item{delta}{positive number} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMiaco}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item de Cesare, L., Myers, D.E., and Posa, D. (2002) FORPRAN programs for space-time modeling. \emph{Computers \& Geosciences} \bold{28}, 205-212. \item de Iaco, S.. Myers, D.E., and Posa, D. (2002) Nonseparable space-time covariance models: some parameteric families. \emph{Math. Geol.} \bold{34}, 23-42. } } \me \seealso{ \command{\link{RMmodel}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMiaco(nu=1, lambda=1.5, delta=0.5) plot(model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMmodel.Rd0000644000176200001440000001167513437301604015235 0ustar liggesusers\name{RMmodel} \alias{RMmodel} \alias{RMmodels} \alias{[,RMmodel,ANY,ANY-method} %] \alias{[<-,RMmodel,ANY,ANY-method} %] \title{Covariance and Variogram Models in \pkg{RandomFields} (RM commands)} \description{ Summary of implemented covariance and variogram models% in \link{RFformula} } \details{ To generate a covariance or variogram model for use within \pkg{RandomFields}, calls of the form \deqn{RM_name_(..., var, scale, Aniso, proj)} can be used, where _name_ has to be replaced by a valid model name. \itemize{ \item \code{...} can take model specific arguments. %Argument %corresponding to specific covariance model \item \code{var} is the optional variance argument \eqn{v}, \item \code{scale} the optional scale argument \eqn{s}, \item \code{Aniso} an optional anisotropy matrix \eqn{A} or given by \command{\link{RMangle}}, and \item \code{proj} is the optional projection. } With \eqn{\phi} denoting the original model, the transformed model is \eqn{C(h) = v * \phi(A*h/s)}. See \command{\link{RMS}} for more details. \command{RM_name_} must be a function of class \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. The return value of all functions \command{RM_name_} is of class \command{\link[=RMmodel-class]{RMmodel}}.\cr The following models are available (cf. \command{\link{RFgetModelNames}}): %Choose from the following covariance models \bold{Basic stationary and isotropic models} \tabular{ll}{ \command{\link{RMcauchy}} \tab Cauchy family \cr \command{\link{RMexp}} \tab exponential model \cr \command{\link{RMgencauchy}} \tab generalized Cauchy family \cr \command{\link{RMgauss}} \tab Gaussian model \cr \command{\link{RMgneiting}} \tab differentiable model with compact support \cr \command{\link{RMmatern}} \tab Whittle-Matern model \cr \command{\link{RMnugget}} \tab nugget effect model \cr \command{\link{RMspheric}} \tab spherical model \cr \command{\link{RMstable}} \tab symmetric stable family or powered exponential model \cr \command{\link{RMwhittle}} \tab Whittle-Matern model, alternative parametrization\cr } \bold{Variogram models (stationary increments/intrinsically stationary)} \tabular{ll}{ \command{\link{RMfbm}} \tab fractal Brownian motion\cr } \bold{Basic Operations} \tabular{ll}{ \command{\link{RMmult}}, \code{*} \tab product of covariance models \cr \command{\link{RMplus}}, \code{+} \tab sum of covariance models or variograms\cr } % \bold{Basic models for mixed effect modelling} % \tabular{ll}{ % \command{\link{RMfixcov}} \tab constant pre-defined covariance \cr % \command{\link{RMfixed}} \tab fixed or trend effects; % caution: \link{RMfixed} is not % a function and can be used only in \link[=RFformula]{formula notation}.\cr % %\command{\link{RMmixed}} \tab Mixture of fixed, mixed, and random effect % %model\cr % gibts nur noch intern % } \bold{Others} \tabular{ll}{ \command{\link{RMtrend}} \tab trend \cr \command{\link{RMangle}} \tab defines a 2x2 anisotropy matrix by rotation and stretch arguments. } % \bold{See \link{RMmodelsAdvanced} for many more, advanced models.\cr % \bold{See \link{spherical models} for models valid on spherical %coordinate systems.} % } } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. % \item Gneiting, T. and Schlather, M. (2004) % Statistical modeling with covariance functions. % \emph{In preparation.} \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. \item Yaglom, A.M. (1987) \emph{Correlation Theory of Stationary and Related Random Functions I, Basic Results.} New York: Springer. \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3nd edition. } } \author{Alexander Malinowski; \martin} \seealso{ \link{RM} for an overview over more advanced classes of models\cr \link{RC}, \link{RF}, \link{RP}, \link{RR}, \link{R.}, \command{\link{RFcov}}, \command{\link{RFformula}}, \command{\link{RMmodelsAdvanced}}, \command{\link{RMmodelsAuxiliary}}, \link{trend modelling} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model) \dontshow{FinalizeExample()}}RandomFields/man/RMmodelsAuxiliary.Rd0000644000176200001440000000701113437301604017275 0ustar liggesusers\name{Others} \alias{AuxiliaryModels} \alias{Auxiliary Models} \alias{Auxiliary RMmodels} \alias{Other models} \alias{RMmodelsAuxiliary} \title{Auxiliary and other Models} \description{ Here, auxiliary models are given that are not covariance functions or variograms, but which might be used within the definition of a model. } \section{Implemented models}{ \bold{Distribution families} See \link{RR}. \bold{Evaluation operators} See \link{RF}. \bold{Random Fields / Random Processes} See \link{RP}. \bold{Mathematical functions} See \link{R.} \bold{Shape functions} Besides any of the covariance functions the following functions can be used as shape functions. \tabular{ll}{ \command{\link{RMangle}} \tab defines an anisotropy matrix by angle and a diagonal matrix \cr \command{\link{RMball}} \tab Indicator of a ball of radius \eqn{1/2} \cr \command{\link{RMm2r}} \tab spectral function belonging to a tail correlation function of the Gneiting class \eqn{H_n} \cr \command{\link{RMm3b}} \tab spectral function belonging to a tail correlation function of the Gneiting class \eqn{H_n} \cr \command{\link{RMmppplus}} \tab operator to define mixed moving maxima (M3) processes \cr \command{\link{RMmps}} \tab spectral functions belonging to a tail correlation function of the Gneiting class \eqn{H_n} \cr \command{\link{RMpolygon}} \tab Indicator of a typical Poisson polygon \cr \command{\link{RMrational}} \tab shape function used in the Bernoulli paper given in the references \cr \command{\link{RMrotat}} \tab shape function used in the Bernoulli paper given in the references \cr \command{\link{RMsign}} \tab random sign \cr \command{\link{RMtruncsupport}} \tab truncates the support of a shape in a Poisson based model \cr } \bold{Special transformations} \tabular{ll}{ \command{\link{RMeaxxa}} \tab shape function used in the Bernoulli paper given in the references \cr \command{\link{RMetaxxa}} \tab shape function used in the Bernoulli paper given in the references \cr \command{\link{RMidmodel}} \tab model identity\cr \command{\link{RMid}} \tab identity but interpretation turns from a coordinate to a model value\cr \command{\link{RMtrafo}} \tab allows to model the identity within the set of coordinates \cr \command{\link{RMrotation}} \tab shape function used in the Bernoulli paper given in the references \cr } \bold{Other models} \tabular{ll}{ \command{\link{RMuser}} \tab User defined covariance model \cr } } %\section{Methods}{ % \describe{ % \item{[}{\code{signature(x = "RFgridDataFrame")}: selects %] % slot by name} % \item{[<-}{\code{signature(x = "RFgridDataFrame")}: replaces % slot by name} % \item{as}{\code{signature(x = "RFgridDataFrame")}: % converts into other formats, only implemented for target class % \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}} } % \item{cbind}{\code{signature(...)}: if arguments have identical % topology, combine their attribute values} % } %} \seealso{ \link{RM}} \author{Alexander Malinowski; \martin} \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames() \dontshow{FinalizeExample()}} RandomFields/man/fitgauss.Rd0000644000176200001440000000407613437301604015520 0ustar liggesusers\name{fitgauss} \alias{fitgauss} %\alias{AIC} %\alias{AICc} %\alias{logLik} \title{Details on fitting Gaussian random fields, including Box-Cox transformation} \description{ Here, some details of \command{\link{RFfit}} are given concerning the fitting of models for Gaussian random fields. \bold{ This documentation is far from being complete. } } % to do : merge with privat/rffitAdvanced.Rd %\usage{} %\arguments{} %\value{} \section{Maximum likelihood}{ The application of the usual maximum likelihood method and reporting the result is the default. } %\section{Restricted maximum likelihood}{ % to do %} %\section{Composed likelihood}{ % to do %} \section{Least squares}{ The weighted least squares methods minimize \deqn{ \sum_{i} w_i (\hat \gamma(h_i) - \gamma(h_i))^2 } over all parametrized models of \eqn{\gamma}. Here, \eqn{i} runs over all \eqn{N} bins of the binned variogram \eqn{\hat \gamma} and \eqn{h_i} is the centre of bin \eqn{i}. The following variants of the least squares methods, passed as \code{sub.methods} in \command{\link{RFfit}} are implemented: \describe{ \item{\code{'self'}}{ \eqn{w_i = (\gamma(h_i))^{-2}} } \item{\code{'plain'}}{\eqn{w_i = 1} for all \eqn{i}. } \item{\code{'sqrt.nr'}}{\eqn{w_i^2} equals the number of points \eqn{n_i} in bin \eqn{i}. } \item{\code{'sd.inv'}}{\eqn{1 / w_i} equals the standard deviation of the variogram cloud within bin \eqn{i}. } \item{\code{'internal'}}{ Three subvariants are implemented: \describe{ \item{\code{'internal1'}}{ \eqn{w_i^2 = (N-i+1) n_i } } \item{\code{'internal2'}}{ \eqn{w_i = N-i+1} } \item{\code{'internal3'}}{ \eqn{w_i^2 = N-i+1} } } } } } \seealso{ \code{\link{RFfit}}, \code{RFfit-class}. } \me \keyword{spatial} \keyword{optimize} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RFfit'. \dontshow{FinalizeExample()}} RandomFields/man/RMfractdiff.Rd0000644000176200001440000000337213437301604016060 0ustar liggesusers\name{RMfractdiff} \alias{RMfractdiff} \title{Fractionally Differenced Process Model} \description{ \command{\link{RMfractdiff}} is a stationary isotropic covariance model. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given for integers \eqn{r \in {\bf N}}{r} by \deqn{C(r) = (-1)^r \frac{ \Gamma(1-a/2)^2 }{ \Gamma(1-a/2+r) \Gamma(1-a/2-r) } r \in {\bf N}}{C(r) = (-1)^r \Gamma(1-a/2)^2 / (\Gamma(1-a/2+r) \Gamma(1-a/2-r))} and otherwise linearly interpolated. Here, \eqn{a \in [-1,1)}{-1 \le a < 1}, \eqn{\Gamma}{\Gamma} denotes the gamma function. It can only be used for one-dimensional random fields. } \usage{ RMfractdiff(a, var, scale, Aniso, proj) } \arguments{ \item{a}{ \eqn{-1 \le a < 1}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The model is only valid for dimension \eqn{d = 1}{d = 1 }. It stems from time series modelling where the grid locations are multiples of the scale parameter. } \value{ \command{\link{RMfractdiff}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } %\references{ % reference missing! %\itemize{ % \item %} %} \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractdiff(0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RRdeterm.Rd0000644000176200001440000000146513437301604015416 0ustar liggesusers\name{RRdeterm} \alias{RRdeterm} \title{Degenerate Distributions} \description{ \command{RRdeterm} refers to the distribution of a deterministic variable. } \usage{ RRdeterm(mean) } \arguments{ \item{mean}{the deterministic value} } \value{ \command{\link{RRdeterm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RRdistr}}, \command{\link{RRgauss}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-2, 2, 0.001) p <- RFpdistr(RRdeterm(mean=1), q=x) plot(x, p, type="l") \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMrotat.Rd0000644000176200001440000000174213437301604015260 0ustar liggesusers\name{RMrotat} \alias{RMrotat} \alias{RMrotation} \title{Rotation matrices} \description{ \command{RMrotat} and \command{RMrotation} are auxiliary space-time functions that create some rotation \deqn{f(h, t) = s (\cos(\phi t) h_1 + \sin(\phi t) h_2) / \|h\|} and \deqn{f(h, t) = (\cos(\phi t) h_1 + \sin(\phi t) h_2, - \sin(\phi t) h_1 + \cos(\phi t) h_2, t),} respectively. } \usage{ RMrotat(speed, phi) RMrotation(phi) } \arguments{ \item{speed}{real value \eqn{s} } \item{phi}{angle} } \details{ \command{\link{RMrotat}} and \command{\link{RMrotation}} are space-time models for two-dimensional space. } \value{ \command{\link{RMrotat}} and \command{\link{RMrotation}} return an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \link{S10}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} # see S10 \dontshow{FinalizeExample()} } RandomFields/man/RFpointsDataFrame-class.Rd0000644000176200001440000001255413437301604020307 0ustar liggesusers\name{RFpointsDataFrame-class} \docType{class} \alias{RFpointsDataFrame-class} \alias{RFpointsDataFrame} %% S4 methods \alias{RFspDataFrame2conventional,RFpointsDataFrame-method} \alias{show,RFpointsDataFrame-method} \alias{coerce,RFpointsDataFrame,RFgridDataFrame-method} \alias{coerce,RFpointsDataFrame,RFgridDataFrame,ANY-method} \alias{[,RFpointsDataFrame-method} \alias{[,RFpointsDataFrame,ANY,ANY-method} \alias{[,RFpointsDataFrame,ANY,ANY,ANY-method} \alias{[<-,RFpointsDataFrame-method} \alias{[<-,RFpointsDataFrame,ANY,ANY,ANY-method} \alias{dimensions,RFpointsDataFrame-method} %\alias{isGridded,RFpointsDataFrame-method} \alias{variance,RFpointsDataFrame-method} %% S3 methods \alias{print.RFpointsDataFrame} \alias{cbind.RFpointsDataFrame} \alias{range.RFpointsDataFrame} \alias{hist.RFpointsDataFrame} \alias{as.matrix.RFpointsDataFrame} \alias{as.array.RFpointsDataFrame} \alias{as.vector.RFpointsDataFrame} \alias{as.data.frame.RFpointsDataFrame} \title{Class \code{RFpointsDataFrame}} \description{ Class for attributes in one-dimensional space that are not on a grid. } \usage{ \S4method{RFspDataFrame2conventional}{RFpointsDataFrame}(obj) } \arguments{ \item{obj}{an \code{RFspatialPointsDataFrame} object} } \section{Creating Objects}{ Objects can be created by using the functions \code{\link{RFpointsDataFrame}} or \code{\link{conventional2RFspDataFrame}} or by calls of the form \code{as(x, "RFpointsDataFrame")}, where \code{x} is of class \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}}. %Ordered full grids are stored instead or unordered non-NA cells; } \section{Slots}{ \describe{ \item{\code{data}:}{object of class \code{\link[methods:data.frame-class]{data.frame}}, containing attribute data } \item{\code{coords}:}{n-times-1 matrix of coordinates (each row is a point)} \item{\code{.RFparams}:}{list of 2; \code{.RFparams$n} is the number of repetitions of the random field contained in the \code{data} slot, \code{.RFparams$vdim} gives the dimension of the values of the random field, equals 1 in most cases} } } \section{Methods}{ \describe{ \item{plot}{\code{signature(obj = "RFpointsDataFrame")}: generates nice plots of the random field; if \eqn{space-time-dim2}, a two-dimensional subspace can be selected using the argument \code{MARGIN}; to get different slices in a third direction, the argument \code{MARGIN.slices} can be used; for more details see \code{\link{plot-method}} or type \code{method?plot("RFpointsDataFrame")}.} \item{show}{\code{signature(x = "RFpointsDataFrame")}: uses the \command{show}-method for class \code{\link[=SpatialPointsDataFrame-class]{SpatialPointsDataFrame}}.} \item{print}{\code{signature(x = "RFpointsDataFrame")}: identical to \command{show}-method} \item{RFspDataFrame2conventional}{\code{signature(obj = "RFpointsDataFrame")}: conversion to a list of non-\pkg{sp}-package based objects; the \code{data}-slot is converted to an array of dimension \eqn{[1*(vdim>1) + space-time-dimension + 1*(n>1)]}} \item{coordinates}{\code{signature(x = "RFpointsDataFrame")}: returns the coordinates} \item{[}{\code{signature(x = "RFpointsDataFrame")}: selects columns of \code{data}-slot; returns an object of class \code{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}}.} \item{[<-}{\code{signature(x = "RFpointsDataFrame")}: replaces columns of \code{data}-slot; returns an object of class \code{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}}.} \item{as}{\code{signature(x = "RFpointsDataFrame")}: converts into other formats, only implemented for target class \code{\link[=RFgridDataFrame-class]{RFgridDataFrame}} } \item{cbind}{\code{signature(...)}: if arguments have identical topology, combine their attribute values} \item{range}{\code{signature(x = "RFpointsDataFrame")}: returns the range } \item{hist}{\code{signature(x = "RFpointsDataFrame")}: plots histogram } \item{as.matrix}{\code{signature(x = "RFpointsDataFrame")}: converts \code{data}-slot to matrix} \item{as.array}{\code{signature(x = "RFpointsDataFrame")}: converts \code{data}-slot to array} \item{as.vector}{\code{signature(x = "RFpointsDataFrame")}: converts \code{data}-slot to vector} \item{as.data.frame}{\code{signature(x = "RFpointsDataFrame")}: converts \code{data}-slot and coordinates to a data.frame} } } \section{Details}{ Methods \command{summary} and \command{dimensions} are defined for the \dQuote{parent}-class \command{\link[=RFsp-class]{RFsp}}. } \author{Alexander Malinowski, \martin} \seealso{ \code{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}}, which is for point locations in higher dimensional spaces, \code{\link{RFpointsDataFrame-class}} which is for one-dimensional locations on a grid, \code{\link[=RFsp-class]{RFsp}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- runif(100) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2) \dontshow{FinalizeExample()}} \keyword{classes} \keyword{print} \keyword{hplot} RandomFields/man/papers.jss14.Rd0000644000176200001440000001571213437301604016127 0ustar liggesusers\name{jss14} \alias{jss14} %\alias{information} %\alias{pars} %\alias{pars.model} %\alias{whole} %\alias{whole.model} \title{Covariance models for multivariate and vector-valued fields} \description{ Here, the code of the paper on \sQuote{Analysis, simulation and prediction of multivariate random fields with package RandomFields} is given. } \me \references{ Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/} } \examples{\dontshow{StartExample()} \dontshow{if (RFoptions()$internal$examples_reduced) RFoptions(modus_operandi="sloppy")} \dontrun{ ########################################### ## SECTION 4: UNCONDITIONAL SIMULATION ## ########################################### RFoptions(seed = 0, height = 4) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## height : height of X11 ## always_close_device=FALSE: the pictures are kept on the screen ## Fig. 1: linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) model <- RMmatrix(M = M1, RMwhittle(nu = 0.3)) + RMmatrix(M = M2, RMwhittle(nu = 2)) x <- y <- seq(-10, 10, 0.2) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 2: Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 4)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') %dev.copy2pdf(file="delay0.pdf") ## Fig. 3: extended Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(0, 4)) + RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') plot(model, dim = 2, xlim = c(-5, 5), main = "Covariance function", cex = 1.5, col = "brown") %dev.copy2pdf(file="delay_cov.pdf") ## Fig. 4: latent dimension model ## MARGIN.slices has the effect of choosing the third dimension ## as latent dimension ## n.slices has the effect of choosing a bivariate model model <- RMgencauchy(alpha = 1.5, beta = 3) simu <- RFsimulate(model, x, y, z = c(0,1)) plot(simu, MARGIN.slices = 3, n.slices = 2) ## Fig. 5: Gneiting's bivariate Whittle-Matern model model <- RMbiwm(nudiag = c(1, 2), nured = 1, rhored = 1, cdiag = c(1, 5), s = c(1, 1, 2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 6: anisotropic linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) A1 <- RMangle(angle = pi/4, diag = c(0.1, 0.5)) A2 <- RMangle(angle = 0, diag = c(0.1, 0.5)) model <- RMmatrix(M = M1, RMgengneiting(kappa = 0, mu = 2, Aniso = A1)) + RMmatrix(M = M2, RMgengneiting(kappa = 3, mu = 2, Aniso = A2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 7: random vector field whose paths are curl free ## A 4-variate field is simulated, where the first component ## refers to the potential field, the second and third component ## to the curl free vector field and the forth component to the ## field of sinks and sources model <- RMcurlfree(RMmatern(nu = 5), scale = 4) simu <- RFsimulate(model, x, y) plot(simu, select.variables = list(1, 2 : 3, 4)) plot(model, dim = 2, xlim = c(-3, 3), main = "", cex = 2.3, col="brown") %dev.copy2pdf(file="curlfree_cov.pdf") ## Fig. 8: Kolmogorov's model of turbulence ## See the physical literature for its derivation and details x <- y <- seq(-2, 2, len = 20) model <- RMkolmogorov() simu <- RFsimulate(model, x, y, z = 1) plot(simu, select.variables = list(1 : 2), col = c("red")) plot(model, dim = 3, xlim = c(-3, 3), MARGIN = 1 : 2, cex = 2.3, fixed.MARGIN = 1.0, main = "", col = "brown") %dev.copy2pdf(file="kolmogorov_cov.pdf") ########################################### ## SECTION 5: DATA ANALYSIS ## ########################################### ## get the data data("weather") PT <- weather[ , 1 : 2] ## full data set takes more than ## half an hour to be analysed ## transformation of earth coordinates to Euclidean coordinates Dist.mat <- as.vector(RFearth2dist(weather[ , 3 : 4])) All <- TRUE \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced data set") All <- 1:10 PT <- weather[All , 1 : 2] Dist.mat <- as.vector(RFearth2dist(weather[All , 3 : 4])) }} ################################# ## model definition ## ################################# ## bivariate pure nugget effect: nug <- RMmatrix(M = matrix(nc = 2, c(NA, 0, 0, NA)), RMnugget()) ## parsimonious bivariate Matern model pars.model <- nug + RMbiwm(nudiag = c(NA, NA), scale = NA, cdiag = c(NA, NA), rhored = NA) ## whole bivariate Matern model whole.model <- nug + RMbiwm(nudiag = c(NA, NA), nured = NA, s = rep(NA, 3), cdiag = c(NA, NA), rhored = NA) ################################# ## model fitting and testing ## ################################# ## 'parsimonious model' ## fitting takes a while ( > 10 min) pars <- RFfit(pars.model, distances = Dist.mat, dim = 3, data = PT) print(pars) print(pars, full=TRUE) RFratiotest(pars) #RFcrossvalidate(pars, x = weather[All , 3 : 4], data = PT, full = TRUE) ## 'whole model' ## fitting takes a while ( > 10 min) whole <- RFfit(whole.model, distances = Dist.mat, dim = 3, data = PT) print(whole, full=TRUE) RFratiotest(whole) #RFcrossvalidate(whole, x = weather[All , 3 : 4], data = PT, full = TRUE) ## compare parsimonious and whole RFratiotest(nullmodel = pars, alternative = whole) ################################# ## kriging ## ################################# ## First, the coordinates are projected on a plane a <- colMeans(weather[All , 3 : 4]) * pi / 180 P <- cbind(c(-sin(a[1]), cos(a[1]), 0), c(-cos(a[1]) * sin(a[2]), -sin(a[1]) * sin(a[2]), cos(a[2])), c(cos(a[1]) * cos(a[2]), sin(a[1]) * cos(a[2]), sin(a[2]))) x <- RFearth2cartesian(weather[All , 3 : 4]) plane <- (t(x) \%*\%P)[ , 1 : 2] ## here, kriging is performed on a rectangular that covers ## the projected points above. The rectangular is approximated ## by a grid of length 200 in each direction. n <- 200 r <- apply(plane, 2, range) dta <- cbind(plane, weather[All , 1 : 2]) z <- RFinterpolate(pars, data = dta, dim = 2, x = seq(r[1, 1], r[2, 1], length = n), y = seq(r[1, 2], r[2, 2], length = n), varunits = c("Pa", "K"), spConform = TRUE) plot(z) } \dontshow{RFoptions(modus_operandi="normal")} \dontshow{FinalizeExample()}} \seealso{ \link{weather}, \link{SS12}, \link{S10}. } \keyword{spatial} RandomFields/man/plot-method.Rd0000644000176200001440000004265213437301604016131 0ustar liggesusers\name{plot-method} \docType{methods} \alias{plot-method} \alias{plot,RFgridDataFrame,missing-method} \alias{plot,RFpointsDataFrame,missing-method} \alias{plot,RFspatialGridDataFrame,missing-method} \alias{plot,RFspatialPointsDataFrame,missing-method} \alias{plot,RFgridDataFrame,matrix-method} \alias{plot,RFpointsDataFrame,matrix-method} \alias{plot,RFspatialGridDataFrame,matrix-method} \alias{plot,RFspatialPointsDataFrame,matrix-method} \alias{plot,RFgridDataFrame,data.frame-method} \alias{plot,RFpointsDataFrame,data.frame-method} \alias{plot,RFspatialGridDataFrame,data.frame-method} \alias{plot,RFspatialPointsDataFrame,data.frame-method} \alias{plot,RFgridDataFrame,RFgridDataFrame-method} \alias{plot,RFgridDataFrame,RFpointsDataFrame-method} \alias{plot,RFpointsDataFrame,RFgridDataFrame-method} \alias{plot,RFpointsDataFrame,RFpointsDataFrame-method} \alias{plot,RFspatialGridDataFrame,RFspatialGridDataFrame-method} \alias{plot,RFspatialGridDataFrame,RFspatialPointsDataFrame-method} \alias{plot,RFspatialPointsDataFrame,RFspatialGridDataFrame-method} \alias{plot,RFspatialPointsDataFrame,RFspatialPointsDataFrame-method} \alias{persp,RFspatialGridDataFrame-method} \alias{contour.RFspatialGridDataFrame} \alias{RFplotSimulation} \alias{RFplotSimulation1D} \title{Methods for function \code{plot} in package \pkg{RandomFields}} \description{ Plot methods are implemented for simulated random fields (objects of class \code{\link[=RFsp-class]{RFsp}}), explicit covariance models (objects of class \code{\link[=RMmodel-class]{RMmodel}}), empirical variograms (objects of class \code{\link[=RFempVariog-class]{RFempVariog}}) and fitted models (objects of class \code{\link[=RFfit-class]{RFfit}}). The plot methods not described here are described together with the class itself, for instance, %\code{\link[=RFempVariog-class]{RFempVariog}}) \code{\link[=RFfit-class]{RFfit}}, \code{\link[=RFempVariog-class]{RFempVariog}} \code{\link[=RMmodel-class]{RMmodel}}. } \section{Methods}{ \describe{ \item{\code{signature(x = "RFspatialGridDataFrame", y = "missing")}}{Generates nice image plots of simulation results for simulation on a grid and space-time-dimension \eqn{\ge 2}{>1}. If space-time-dimension \eqn{\ge 3}{>2}, plots are on 2-dimensional subspaces. Handles multivariate random fields (\code{.RFparams$vdim>1}) as well as repeated iid simulations (\code{.RFparams$vdim>n}).} \item{\code{signature(x = "RFspatialGridDataFrame", y = "RFspatialPointsDataFrame")}}{ Similar to method for \code{y="missing"}, but additionally adds the points of \code{y}. Requires \code{MARGIN.slices=NULL} and \code{all.equal(x@.RFparams, y@.RFparams)}.} \item{\code{signature(x = "RFspatialGridDataFrame", y = "matrix")}}{ Similar to method for \code{y="missing"}, but additionally adds the points of \code{y}. Requires \code{MARGIN.slices=NULL} and \code{all.equal(x@.RFparams, y@.RFparams)}.} \item{\code{signature(x = "RFspatialPointsDataFrame", y = "RFspatialGridDataFrame")}}{ Throws an error. Probably \code{x} and \code{y} have been interchanged.} \item{\code{signature(x = "RFspatialPointsDataFrame", y = "missing")}}{Similar to method for class \code{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}}, but for non-gridded simulation results. Instead of a grid, only existing points are plotted with colors indicating the value of the random field at the respective location. Handles multivariate random fields (\code{.RFparams$vdim>1}) as well as repeated iid simulations (\code{.RFparams$vdim>n}).} \item{\code{signature(x = "RFspatialPointsDataFrame", y = "RFspatialPointsDataFrame")}}{ Similar to method for \code{y="missing"}, but additionally adds the points of \code{y}. Requires \code{all.equal(x@.RFparams, y@.RFparams)}.} \item{\code{signature(x = "RFgridDataFrame", y = "missing")}}{Generates plots of simulation results for space-time-dimension \eqn{=1}. Handles different values for the number of repetitions as well as multivariate responses.} \item{\code{signature(x = "RFpointsDataFrame", y = "missing")}}{Similar to method for class \code{\link[=RFgridDataFrame-class]{RFgridDataFrame}}, but for non-gridded data.} } %% 2.1.3 Documenting S4 classes and methods %% ---------------------------------------- %% There are special ways to use the ? operator, namely class?TOPIC %% and methods?TOPIC, to access documentation for S4 classes and %% methods, respectively. This mechanism depends on conventions for the %% topic names used in alias entries. The topic names for S4 classes %% and methods respectively are of the form %% CLASS-class %% GENERIC,SIGNATURE_LIST-method %% where SIGNATURE_LIST contains the names of the classes in the signature %% of the method (without quotes) separated by , (without whitespace), %% with ANY used for arguments without an explicit specification. E.g., %% genericFunction-class is the topic name for documentation for the S4 %% class "genericFunction", and coerce,ANY,NULL-method is the topic %% name for documentation for the S4 method for coerce for signature %% c("ANY", "NULL"). %% Skeletons of documentation for S4 classes and methods can be %% generated by using the functions promptClass() and promptMethods() %% from package *methods*. If it is necessary or desired to provide an %% explicit function declaration (in a usage section) for an S4 method %% (e.g., if it has \sQuote{surprising arguments} to be mentioned explicitly), %% one can use the special markup %% % \S4method{GENERIC}{SIGNATURE_LIST}(ARGUMENT_LIST) %% %(e.g., \S4method{coerce}{ANY,NULL}(from, to)). %% To allow for making full use of the potential of the on-line %% documentation system, all user-visible S4 classes and methods in a %% package should at least have a suitable alias entry in one of the %% packages Rd files. If a package has methods for a function defined %% originally somewhere else, and does not change the underlying default %% method for the function, the package is responsible for documenting the %% methods it creates, but not for the function itself or the default %% method. %% See help("Documentation", package = "methods") for more %% information on using and creating on-line documentation for S4 classes %% and methods. } \usage{ RFplotSimulation(x, y, MARGIN=c(1,2), MARGIN.slices=NULL, n.slices = if (is.null(MARGIN.slices)) 1 else 10, nmax=6, plot.variance = !is.null(x@.RFparams$has.variance) && x@.RFparams$has.variance, select.variables, zlim, legend=TRUE, MARGIN.movie = NULL, file=NULL, speed = 0.3, height.pixel=300, width.pixel=height.pixel, ..., plotmethod="image") RFplotSimulation1D(x, y, nmax=6, plot.variance=!is.null(x@.RFparams$has.variance) && x@.RFparams$has.variance, legend=TRUE, ...) \S4method{plot}{RFgridDataFrame,missing}(x, y, ...) \S4method{plot}{RFpointsDataFrame,missing}(x, y, ...) \S4method{plot}{RFspatialGridDataFrame,missing}(x, y, ...) \S4method{plot}{RFspatialPointsDataFrame,missing}(x, y, ...) \S4method{plot}{RFgridDataFrame,matrix}(x, y, ...) \S4method{plot}{RFpointsDataFrame,matrix}(x, y, ...) \S4method{plot}{RFspatialGridDataFrame,matrix}(x, y, ...) \S4method{plot}{RFspatialPointsDataFrame,matrix}(x, y, ...) \S4method{plot}{RFgridDataFrame,data.frame}(x, y, ...) \S4method{plot}{RFpointsDataFrame,data.frame}(x, y, ...) \S4method{plot}{RFspatialGridDataFrame,data.frame}(x, y, ...) \S4method{plot}{RFspatialPointsDataFrame,data.frame}(x, y, ...) \S4method{plot}{RFgridDataFrame,RFgridDataFrame}(x, y, ...) \S4method{plot}{RFgridDataFrame,RFpointsDataFrame}(x, y, ...) \S4method{plot}{RFpointsDataFrame,RFgridDataFrame}(x, y, ...) \S4method{plot}{RFpointsDataFrame,RFpointsDataFrame}(x, y, ...) \S4method{plot}{RFspatialGridDataFrame,RFspatialGridDataFrame}(x, y, ...) \S4method{plot}{RFspatialGridDataFrame,RFspatialPointsDataFrame}(x, y, ...) \S4method{plot}{RFspatialPointsDataFrame,RFspatialGridDataFrame}(x, y, ...) \S4method{plot}{RFspatialPointsDataFrame,RFspatialPointsDataFrame}(x, y, ...) \S4method{persp}{RFspatialGridDataFrame}(x, ..., zlab="") \S3method{contour}{RFspatialGridDataFrame}(x, ...) } \arguments{ \item{x}{object of class \code{\link[=RFsp-class]{RFsp}} or \command{\link[=RMmodel-class]{RMmodel}}; in the latter case, \code{x} can be any sophisticated model but it must be either stationary or a variogram model} \item{y}{ignored in most methods; in case of \command{RFplotSimulation} data might be given} \item{MARGIN}{vector of two; two integer values giving the coordinate dimensions w.r.t. whether the field or the covariance model is to be plotted; in all other directions, the first index is taken} \item{MARGIN.slices}{integer value; if \eqn{[space-time-dimension>2]}, \code{MARGIN.slices} can specify a third dimension w.r.t. which a sequence of slices is plotted. Currently only works for grids.} % \item{fixed.MARGIN}{only for \code{class(x)==CLASS_CLIST} and if % \code{dim > 2}; a vector of length \code{dim}-2 with distance values % for the coordinates that are not displayed} \item{n.slices}{integer value. The number of slices to be plotted; if \code{n.slices>1}, \code{nmax} is set to 1. Or \code{n.slices} is a vector of 3 elements: start, end, length. Currently only works for grids.} \item{nmax}{the maximal number of the \code{x@.RFparams$n} iid copies of the field that are to be plotted} \item{MARGIN.movie}{integer. If given a sequence of figures is shown for this direction. This option is in an experimental stage. It works only for grids. } \item{file, speed, height.pixel, width.pixel}{ In case \code{MARGIN.movie} and \code{file} is given an 'avi' movie is stored using the \command{mencoder} command with speed argument \code{speed}. As temporary files \code{file__###.png} of size \code{width.pixel} x \code{height.pixel} are created. } \item{...}{arguments to be passed to methods; mainly graphical arguments, or further models in case of class \code{CLASS_CLIST}, see Details. } % \item{f i tmethod}{character; only for \code{class(x)=="RFfit"}; a % vector of slot names for which the fitted covariance or variogram % model is to be plotted; should be a subset of % \code{slotNames(x)} for which the corresponding slots are of class % \code{CLASS_FIT}; by default, the maximum likelihood fit will be % plotted} % \item{dim}{must equal 1 or 2; only for \code{class(x)==CLASS_CLIST}; the % covariance function and the variogram are plotted as a function of % \eqn{\R^\code{dim}}{R^\code{dim}}.} % \item{n.points}{integer; only for \code{class(x)==CLASS_CLIST}; the % number of points at which the model % evaluated (in each dimension); defaults to 200} % \item{fct.type}{character; only for \code{class(x)==CLASS_CLIST}; must % equal \code{NULL}, \code{"Cov"} or \code{"Variogram"}; controls % whether the covariance (\code{fct.type="Cov"}) or the % variogram (\code{fct.type="Variogram"}) is plotted; \code{NULL} % implies automatic choice, where \code{"Cov"} is chosen whenever the model is % stationary} % \item{model}{object of class % \command{\link[=RMmodel-class]{RMmodel}}; only for % \code{class(x)=="RFempVario"} or \code{class(x)=="RFfit"}; a list of % covarianve or variogram models that are to be plotted into the same % plot as the empirical variogram (and the fitted models)} \item{plot.variance}{logical, whether variances should be plotted if available} \item{select.variables}{vector of integers or list of vectors. The argument is only of interest for multivariate models. Here, \code{length(select.variables)} gives the number of pictures shown (excluding the plot for the variances, if applicable). If \code{select.variables} is a vector of integers then exactly these components are shown. If \code{select.variables} is a list, each element should be a vector up to length \eqn{l\le 3}{l <= 3}: \itemize{ \item \eqn{l=1}\cr the component is shown in the usual way \item \eqn{l=2} \cr the two components are interpreted as vector and arrows are plotted \item \eqn{l=3} \cr the first component is shown as single component; the remaining two component are interpreted as a vector and plotted into the picture of the first component } } \item{legend}{logical, whether a legend should be plotted} \item{zlim}{vector of length 2 with the usual meaning. In case of multivariate random fields, \code{zlim} can also be a character with the value \sQuote{joint} indicating that all plotted components shall have the same zlim OR a matrix with two rows, where the i-th column gives the zlim of the i-th variable OR a list with entries named \code{data} and \code{var} if a separate \code{zlim} for the Kriging variance is to be used.} \item{plotmethod}{string or function. Internal. } \item{zlab}{character. See \command{\link[graphics]{persp}}} % \item{maxchar}{maximum number of characters used in the legend % (for multiplots only) } } \details{ Internally, \code{...} are passed to \code{image} and \code{plot.default}, respectively; if, by default, multiple colors, xlabs or ylabs are used, also vectors of suitable length can be passed as \code{col}, \code{xlab} and \code{ylab}, respectively. One exception is the use of \code{...} in \command{plot} for class \code{CLASS_CLIST}. Here, further models might be passed. All models must have names starting with \code{model}. If \code{'.'} is following in the name, the part of the name after the dot is shown in the legend. Otherwise the name is ignored and a standardized name derived from the model definition is shown in the legend. Note that for the first argument a name cannot be specified. } \author{Alexander Malinowski, \martin} \seealso{ \command{\link{RFpar}}. } \keyword{methods} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## define the model: model <- RMtrend(mean=0.5) + # mean RMstable(alpha=1, var=4, scale=10) + # see help("RMstable") ## for additional arguments RMnugget(var=1) # nugget ############################################################# ## Plot of covariance structure plot(model) plot(model, xlim=c(0, 30)) plot(model, xlim=c(0, 30), fct.type="Variogram") plot(model, xlim=c(-10, 20), fct.type="Variogram", dim=2) image(model, xlim=c(-10, 20), fct.type="Variogram") persp(model, xlim=c(-10, 20), fct.type="Variogram") ############################################################# ## Plot of simulation results ## define the locations: from <- 0 step <- .1 len <- 50 # nicer if len=100 %ok \dontshow{if(RFoptions()$internal$examples_red){warning("reduced 'len'"); len<-3}} x1D <- GridTopology(from, step, len) x2D <- GridTopology(rep(from, 2), rep(step, 2), rep(len, 2)) x3D <- GridTopology(rep(from, 3), rep(step, 3), rep(len, 3)) ## 1-dimensional sim1D <- RFsimulate(model = model, x=x1D, n=6) plot(sim1D, nmax=4) ## 2-dimensional sim2D <- RFsimulate(model = model, x=x2D, n=6) plot(sim2D, nmax=4) plot(sim2D, nmax=4, col=terrain.colors(64), main="My simulation", xlab="my_xlab") ## 3-dimensional model <- RMmatern(nu=1.5, var=4, scale=2) sim3D <- RFsimulate(model = model, x=x3D) plot(sim3D, MARGIN=c(2,3), MARGIN.slices=1, n.slices=4) ############################################################# ## empirical variogram plots x <- seq(0, 10, 0.05) bin <- seq(from=0, by=.2, to=3) model <- RMexp() X <- RFsimulate(model, x=cbind(x)) ev1 <- RFvariogram(data=X, bin=bin) plot(ev1) model <- RMexp(Aniso = cbind(c(10,0), c(0,1))) X <- RFsimulate(model, x=cbind(x,x)) ev2 <- RFvariogram(data=X, bin=bin, phi=3) plot(ev2, model=list(exp = model)) \dontshow{\dontrun{ ############################################################# ## plot Fitting results x <- seq(0, 1, len=21) model <- RMexp(Aniso = cbind(c(10,0), c(0,1))) X <- RFsimulate(model, x=cbind(x,x)) fit <- RFfit(~RMexp(Aniso=cbind(c(NA, 0), c( 0, NA))), data=X, fit.nphi = 2, modus="easygoing") plot(fit) }} ############################################################# ## plot Kriging results model <- RMwhittle(nu=1.2, scale=2) n <- 200 x <- runif(n, max=step*len/2) y <- runif(n, max=step*len/2) # 200 points in 2 dimensional space sim <- RFsimulate(model, x=x, y=y) interpolate <- RFinterpolate(model, x=x2D, data=sim) plot(interpolate) plot(interpolate, sim) ############################################################# ## plotting vector-valued results model <- RMdivfree(RMgauss(), scale=4) x <- y <- seq(-10,10, 0.5) simulated <- RFsimulate(model, x=x, y=y, n=1) plot(simulated) plot(simulated, select.variables=list(1, 1:3, 4)) ############################################################# ## options for the zlim argument model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(0, 4)) + RMdelay(RMstable(alpha=1.9, scale=2), s=c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim=list(data=cbind(c(-6,2), c(-2,1)), var=c(5,6))) plot(simu, zlim=cbind(c(-6,2), c(-2,1))) plot(simu, zlim=c(-6,2)) plot(simu, zlim="joint") \dontshow{FinalizeExample()}} RandomFields/man/RFgetModelNames.Rd0000644000176200001440000002524213437301604016645 0ustar liggesusers\name{RFgetModelNames} \alias{RFgetModelNames} %\alias{PrintModelList} \title{Names of implemented covariance and variogram models} \description{Displays the names of covariance and variogram models (see \command{\link{RMmodel}}) and returns them as a list. The user may specify and group the models according to the following properties: \itemize{ \item type of function (\code{"positive definite"}, \code{"variogram"}, etc.) \item whether the function depends on two arguments (\code{"kernel"}) or on one argument only (\code{"single variable"}) \item types of isotropy \item whether the model is an operator \item whether the model is a normal scale mixture \item whether the model has a finite range covariance \item validity in certain dimensions of the coordinate space \item maximal possible dimension of the coordinate space \item uni- or multivariety } See \command{Details} for an explanation and \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} for possible states (values) of these properties. } \usage{ RFgetModelNames(type = RC_TYPE_NAMES, domain = RC_DOMAIN_NAMES, isotropy = RC_ISO_NAMES, operator = c(TRUE, FALSE), monotone = RC_MONOTONE_NAMES, implied_monotonicities = length(monotone) == 1, finiterange = c(TRUE, FALSE, NA), valid.in.dim = c(1, Inf), vdim = c(1, 5), group.by, exact.match = !missing(group.by), simpleArguments = FALSE, internal, newnames) } \arguments{ \item{type, domain, isotropy, operator, monotone, finiterange, vdim}{ see \link{constants} for the definition of \code{RC_TYPE_NAMES}, \code{RC_DOMAIN_NAMES}, etc. See also \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. } \item{implied_monotonicities}{logical. If \code{TRUE} then all the models with a stronger monotonocity than the required one are also shown. } \item{valid.in.dim}{an optional integer indicating the dimension of the space where the model is valid} \item{group.by}{an optional character string or \code{NULL}; must be one of \code{'type'}, \code{'domain'}, \code{'isotropy'}, \code{'operator'}, \code{'monotone'}, \code{'finiterange'},\code{'maxdim'},\code{'vdim'}. If \code{group.by} is not given, the result is grouped by \code{'type'} if more than one type is given. } \item{exact.match}{logical. If not \code{TRUE}, then all categories that are subclasses or might match are show as well. } \item{simpleArguments}{logical. If \code{TRUE}, only models are considered whose arguments are all integer or real valued. } \item{internal, newnames}{both logical; \code{internal} might be also integer valued. If any of them are given, \command{\link{RFgetModelNames}} behaves very differently. See the Notes below. } } \note{ In case \code{internal} or \code{newnames} is given, only the values of \code{internal}, \code{newnames} and \code{operator} are considered. All the other arguments are ignored and \command{\link{RFgetModelNames}} prints a table of the currently implemented covariance functions and the matching methods: \itemize{ \item \code{internal}:\cr if \code{TRUE} also \code{\link{RMmodels}} are listed that are internal, hence invisible to the user. Default: \code{FALSE}. \item \code{newnames}:\cr The model names of version 2 of \pkg{RandomFields} and earlier can still be used in the model definitions. Namely when the list notation is chosen; see \link{Advanced RMmodels} for the latter. If \code{internal} or \code{newnames} is given, then these old names are shown; if \code{newnames=TRUE} then also the usual names are shown. Default: \code{FALSE}. In fact, both internal and public models can have different variants implemented. These variants are also shown if \code{internal} has a value greater than or equal to \code{2}, \item \code{operator}:\cr see above. } Here, also an indication is given, which method for simulating Gaussian random fields matches the model. } \details{ The plain call \code{\link{RFgetModelNames}()} simply gives back a vector of the names of all implemented covariance and variogram models and operators, i.e. members of the class \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. The following arguments can be specified. In general, only exact matches are returned. One exception exists: If the length of \code{type} equals 1 and if \code{group.by} is not given, then types included in \code{type} are also returned. E.g. if \code{type="variogram"} and \code{group.by} is not given then only models are returned that are negative definite. However, also positive definite functions and tail correlaton functions are returned if \code{"type"} is included in \code{group.by}. \describe{ \item{\code{type}}{specifies the class of functions; for the meaning of the possible values see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{stationarity}}{specifies the type of stationarity; for the meaning of the possible values see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{isotropy}}{specifies the type of isotropy; for the meaning of the possible values see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{operator}}{indicates whether the model is an operator, i.e. it requires at least one submodel, e.g. \command{\link[=RMplus]{+}} or \command{\link{RMdelay}} are operators; see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{monotone}}{indicates what kind of monotonicity is known, e.g., whether the model is a normal scale mixture, the latter including \command{\link{RMexp}} or \command{\link{RMcauchy}}; see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{finiterange}}{indicates whether the covariance of the model has finite range, e.g. \command{\link{RMcircular}} or \command{\link{RMnugget}} have covariances with finite range; see \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. \code{NA} is used if the finiteness depends on the submodel. } \item{\code{valid.in.dim}}{If \code{valid.in.dim=n} is passed, all models which are valid in dimension \eqn{n} are displayed. Otherwise \code{valid.in.dim} should be a bivariate vector giving the range of requested dimensions. } \item{\code{maxdim}}{if a positive integer, it specifies the maximal possible dimension of the coordinate space; note that a model which is valid in dimension \eqn{n} is also valid in dimension \eqn{n-1}; \code{maxdim=-1} means that the maximal possible dimension depends on the parameters of the \command{\link{RMmodel}} object; \code{maxdim=-2} means that the maximal possible dimension is adopted from the called submodels; see also \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \item{\code{vdim}}{if a positive integer, vdim specifies, whether the model is \eqn{vdim}-variate; \code{vdim=-1} means that being multivariate in a certain dimension depends on the parameters of the \command{\link{RMmodel}} object; \code{vdim=-2} means that being multivariate in a certain dimension is adopted from the called submodels; see also \command{\link[=RMmodelgenerator-class]{RMmodelgenerator}} If \code{vdim} is bivariate then a range is given. } \item{\code{group.by}}{If \code{group.by="propertyname"} is passed, the displayed models are grouped according to \code{propertyname}. } } All arguments allow also for vectors of values. In case of \code{valid.in.dim} the smallest value is taken. The interpretation is canonical. Note that the arguments \code{stationarity}, \code{isotropy}, \code{operator}, \code{monotone}, \code{finiterange}, \code{maxdim}, \code{vdim} are also slots (attributes) of the SP4-class \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}. } \value{ Either a vector of model names if the argument \code{group.by} is not used; or a list of vectors of model names if the argument \code{group.by} is used (with list elements specified by the categories of the grouping argument). In case \code{internal} or \code{newnames} is given, \command{\link{RFgetModelNames}} prints a table of the currently implemented covariance functions and the matching methods. \command{\link{RFgetModelNames}} returns \code{NULL}. } %\references{ %} \me \seealso{ \link{constants}, \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}, \code{\link{RMmodel}}, \code{\link[=RandomFields-package]{RandomFields}}, \link{RC_DOMAIN_NAMES}, \link{RC_ISO_NAMES} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # get list of names of all functions RFgetModelNames() # any kind of positive definite functions RFgetModelNames(type="positive definite", exact.match=TRUE) \dontrun{RFgetModelNames(type="positive definite")} # get a list of names of all stationary models RFgetModelNames(type="positive definite", domain="single variable", exact.match=TRUE) \dontrun{RFgetModelNames(type="positive definite", domain="single variable")} # get a vector of all model names RFgetModelNames(group.by=NULL) \dontshow{\dontrun{ # get list of all univariate stationary models # additionally grouped by the isotropy attribute str(RFgetModelNames(type="positive definite", domain="single variable", vdim=1, group.by="isotropy")) # get vector of all models which are operators # and valid in the two-dimensional coordinate space RFgetModelNames(type=c("tail correlation function", "positive definite", "variogram", "undefined"), operator=TRUE, valid.in.dim=2) # processes and covariance function grouped by the stationarity # argument and subsequently grouped by the isotropy argument str(RFgetModelNames(type=c("positive definite", "variogram", "process"), group.by=c("type", "domain", "isotropy"))) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMcoxisham.Rd0000644000176200001440000000565113437301604015745 0ustar liggesusers\name{RMcoxisham} \alias{RMcoxisham} \title{Cox Isham Covariance Model} \description{ \command{\link{RMcoxisham}} is a stationary covariance model which depends on a univariate stationary isotropic covariance model \eqn{C_0}, which is a normal scale mixture. The corresponding covariance function only depends on the difference \eqn{(h,t) \in {\bf R}^{d+1}={\bf R}^d\times{\bf R}}{(h,t)} between two points in \eqn{d+1}-dimensional space and is given by \deqn{C(h,t)=|E + t^\beta D|^{-1/2} C_0([(h - t \mu)^T (E + t^\beta D)^{-1} (h - t \mu)]^{1/2})} Here \eqn{\mu \in {\bf R}^d}{\mu} is a vector in \eqn{d}-dimensional space; \eqn{E} is the \eqn{d \times d}{d x d}-identity matrix and \eqn{D} is a \eqn{d \times d}{d x d}-correlation matrix with \eqn{|D| > 0}. The parameter \eqn{\beta} is in \eqn{(0,2]}. Currently, the implementation is done only for \eqn{d=2}. } \usage{ RMcoxisham(phi,mu,D,beta,var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary isotropic covariance model for random fields on \eqn{d}-dimensional space, which is moreover a normal scale mixture, that means an \command{\link{RMmodel}} whose \code{monotone} property equals \code{'normal mixture'}, see \cr \code{\link{RFgetModelNames}(monotone="normal mixture")} \cr and whose \code{maxdim} is at least 2.} \item{mu}{a vector in \eqn{d}-dimensional space} \item{D}{a \eqn{d \times d}{d x d}-correlation matrix with \eqn{|D| > 0}} \item{beta}{numeric in the interval \eqn{(0,2]}; default value is 2 } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model stems from a rainfall model (cf. Cox, D.R., Isham, V.S. (1988)) and equals the following expectation \deqn{C(h,t)=\bold{E}_V C_0(h-Vt)} where the random wind speed vector \eqn{V} follows a \eqn{d}-variate normal distribution with expectation \eqn{mu} and covariance matrix \eqn{D/2} (cf. Schlather, M. (2010), Example 9). } \value{ \command{\link{RMcoxisham}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Cox, D.R., Isham, V.S. (1988) A simple spatial-temporal model of rainfall. \emph{Proc. R. Soc. Lond. A}, \bold{415}, 317-328. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcoxisham(RMgauss(), mu=1, D=1) x <- seq(0, 10, 0.3) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x)) \dontshow{FinalizeExample()}} RandomFields/man/RMsinepower.Rd0000644000176200001440000000420013437301604016132 0ustar liggesusers\name{RMsinepower} \alias{RMsinepower} \alias{sine power function} \title{The Sinepower Covariance Model on the Sphere} \description{ \command{\link{RMsinepower}} is an isotropic covariance model. The corresponding covariance function, the sine power function of Soubeyrand, Enjalbert and Sache, only depends on the angle \eqn{\theta \in [0,\pi]}{0 \le \theta \le \pi} between two points on the sphere and is given by \deqn{\psi(\theta) = 1 - ( sin\frac{\theta}{2} )^{\alpha}}{\psi(\theta) = 1 - ( sin(\theta/2) )^{\alpha},} where \eqn{\alpha\in (0,2]}{0 < \alpha \le 2}. } \usage{ RMsinepower(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value in \eqn{(0,2]}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ For the sine power function of Soubeyrand, Enjalbert and Sache, see Gneiting, T. (2013), equation (17). For a more general form see \command{\link{RMchoquet}}. } \value{ \command{\link{RMsinepower}} returns an object of class \command{\link[=RMmodel-class]{RMmodel}}. } \references{ Gneiting, T. (2013) \emph{Strictly and non-strictly positive definite functions on spheres} \emph{Bernoulli}, \bold{19}(4), 1327-1349. } \author{Christoph Berreth; \martin} \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{spherical models}}, \command{\link{RMchoquet}} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMsinepower(alpha=1.7) plot(model, dim=2) ## the following two pictures are the same x <- seq(0, 0.4, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto") \dontshow{FinalizeExample()}}RandomFields/man/RMscale.Rd0000644000176200001440000000314713437301604015217 0ustar liggesusers\name{RMscale} \alias{RMscale} \title{Scale model for arbitrary areas of scales} \description{ Let \eqn{s_x} the scaling at location \eqn{x} and \eqn{p} a bijective penalizing function for (different) scales. Then covariance function is given by \deqn{C(x,y) = \phi(\|x-y\| + |p(s_x) - p(s_y)|)} } \usage{ RMscale(phi, scaling, penalty, var, scale, Aniso, proj) } \arguments{ \item{phi}{isotropic submodel} \item{scaling}{model that gives the non-stationary scaling \eqn{s_x}} \item{penalty}{bijective function \eqn{p} applied to the \code{scaling}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMscale}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation. } } \me \seealso{ \command{\link{RMSadvanced}}, \command{\link{RMblend}}, \command{\link{RMbubble}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, 0.01) scale <- RMcovariate(x=c(0,1), y=c(1,0),#2 areas separated by the 1st bisector grid=FALSE, data=c(1, 3)) model <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(z <- RFsimulate(model, x, x)) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMbistable.Rd0000644000176200001440000000316013437301604015710 0ustar liggesusers\name{RMbistable} \alias{RMbistable} \title{Bivariate stable Model} \description{ \command{\link{RMbistable}} is a bivariate stationary isotropic covariance model whose corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points. % and is given for \eqn{i,j \in \{1,2\}}{i,j = 1,2} by % \deqn{C_{ij}(r)=[to be done].} For constraints on the constants see Details. } \usage{ RMbistable(alpha, s, cdiag, rho, rhored, betared, alphadiag, var, scale, Aniso, proj) } \arguments{ \item{alpha,alphadiag}{[to be done]} \item{s}{a vector of length 3 of numerical values; each entry positive; the vector \eqn{(s_{11},s_{21},s_{22})}} \item{cdiag}{[to be done]} \item{rho,rhored}{[to be done] } \item{betared}{to do } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Constraints on the constants: [to be done] } \value{ \command{\link{RMbistable}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Moreva, O., Schlather, M. (2016) Modelling and simulation of bivariate Gaussian random fields. \emph{arXiv 1412.1914} } } \me \seealso{ \command{\link{RMstable}}, \link{Multivariate RMmodels}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo \dontshow{FinalizeExample()} }RandomFields/man/RMstp.Rd0000644000176200001440000000472713437301604014743 0ustar liggesusers\name{RMstp} \alias{RMstp} \alias{RMstp} \title{Single temporal process} \description{ \command{\link{RMstp}} is a univariate covariance model which depends on a normal mixture submodel \eqn{\phi}{phi}. The covariance is given by \deqn{ C(x,y) = |S_x|^{1/4} |S_y|^{1/4} |A|^{-1/2} \phi(Q(x,y)^{1/2}) } where \deqn{ Q(x,y) = c^2 - m^2 + h^t (S_x + 2(m + c)M) A^{-1} (S_y + 2 (m-c)M)h, } \deqn{ c = -z^t h + \xi_2(x) - \xi_2(y), } \deqn{ A = S_x + S_y + 4 M h h^t M } \deqn{ m = h^t M h } \deqn{ h = x - y } } \usage{ RMstp(xi, phi, S, z, M, var, scale, Aniso, proj) } \arguments{ \item{xi}{arbitrary univariate function on \eqn{R^d}} \item{phi}{an \command{\link{RMmodel}} that is a normal mixture model, cf.\cr \code{RFgetModelNames(monotone="normal mixture")} } \item{S}{functions that returns strictly positive definite \eqn{d\times d}{d x d}} \item{z}{arbitrary vector, \eqn{z \in R^d}} \item{M}{an arbitrary, symmetric \eqn{d \times d}{d x d} matrix} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ See Schlather (2008) formula (13). The model allows for mimicking cyclonic behaviour. } \value{ \command{\link{RMstp}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Paciorek C.J., and Schervish, M.J. (2006) Spatial modelling using a new class of nonstationary covariance functions, \emph{Environmetrics} \bold{17}, 483-506. \item Schlather, M. (2010) Some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstp(xi = RMrotat(phi= -2 * pi, speed=1), phi = RMwhittle(nu = 1), M=matrix(nc=3, rep(0, 9)), S=RMetaxxa(E=rep(1, 3), alpha = -2 * pi, A=t(matrix(nc=3, c(2, 0, 0, 1, 1 , 0, 0, 0, 0)))) ) x <- seq(0, 10, 0.7) plot(RFsimulate(model, x=x, y=x, z=x)) \dontshow{FinalizeExample()}} RandomFields/man/RMlgd.Rd0000644000176200001440000000452013437301604014672 0ustar liggesusers\name{RMlgd} \alias{RMlgd} \title{Local-Global Distinguisher Family Covariance Model} \description{ \command{\link{RMlgd}} is a stationary isotropic covariance model, which is valid only for dimensions \eqn{d =1,2}{d =1,2}. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) =1 - \beta^{-1}(\alpha + \beta)r^{\alpha} 1_{[0,1]}(r) + \alpha^{-1}(\alpha + \beta)r^{-\beta} 1_{r>1}(r) }{C(r) =1 - \beta^(-1)(\alpha + \beta)r^(\alpha) 1_{[0,1]}(r) + \alpha^(-1)(\alpha + \beta)r^(-\beta) 1_{r>1}(r) } where \eqn{\beta >0} and \eqn{0 < \alpha \le (3-d)/2}{0 < \alpha \le (3-d)/2}, with \eqn{d}{d} denoting the dimension of the random field. } \usage{ RMlgd(alpha, beta, var, scale, Aniso, proj) } \arguments{ \item{alpha}{argument whose range depends on the dimension of the random field: \eqn{0< \alpha \le (3-d)/2}{0< \alpha \le (3-d)/2}.} \item{beta}{positive number} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model is only valid for dimension \eqn{d=1,2}{d=1,2}. This model admits simulating random fields where fractal dimension \emph{D} of the Gaussian sample and Hurst coefficient \emph{H} can be chosen independently (compare also \command{\link{RMgencauchy}}): Here, the random field has fractal dimension \deqn{D = d+1 - \alpha/2}{D = d+1 - \alpha/2} and Hurst coefficient \deqn{H = 1-\beta/2}{H = 1-\beta/2} for \eqn{0< \beta \le 1}{0< \beta \le 1}. } \value{ \command{\link{RMlgd}} returns an object of class \command{\link{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlgd(alpha=0.7, beta=4, scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMtrend.Rd0000644000176200001440000001566213437301604015251 0ustar liggesusers\name{RMtrend} \alias{RMtrend} \alias{trend} \alias{RM_TREND} \title{Trend Model} \description{ \command{\link{RMtrend}} is a pure trend model with covariance 0. } \usage{ RMtrend(mean) %, plane, polydeg, polycoeff, arbitraryfct, fctcoeff) } \arguments{ % to do orthogonale Polynome \item{mean}{numeric or \link{RMmodel}. If it is numerical, it should be a vector of length \eqn{p}{p}, where \eqn{p}{p} is the number of variables taken into account by the corresponding multivariate random field \eqn{(Z_1(\cdot),\ldots,Z_p(\cdot))}{(Z_1(.),\ldots,Z_p(.))}; the \eqn{i}{i}-th component of \code{mean} is interpreted as constant mean of \eqn{Z_i(\cdot)}{Z_i(.)}. } % \item{plane, polydeg, polycoeff,arbitraryfct,fctcoeff}{ % argument currently not maintained anymore.} } \details{ Note that this function refers to trend surfaces in the geostatistical framework. Fixed effects in the mixed models framework are also being implemented, see \command{\link{RFformula}}. } \note{ Using uncapsulated subtraction to build up a covariance function is ambiguous, see the examples below. Best to define the trend separately, or to use \command{\link{R.minus}}. } \value{ \command{\link{RMtrend}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{Chiles, J. P., Delfiner, P. (1999) \emph{Geostatistics: Modelling Spatial Uncertainty.} New York: John Wiley & Sons. } \author{\marco; \martin} \seealso{ \command{\link{RMmodel}}, \command{\link{RFformula}}, \command{\link{RFsimulate}}, \command{\link{RMplus}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## first simulate some data with a sine and a mean as trend repet <- 100 \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced 'repet'"); repet <- 3}} x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model1 <- RMexp(var=2, scale=1) + trend dta <- RFsimulate(model1, x=x, n=repet) ## now, let us estimate variance, scale, and two parameters of the trend model2 <- RMexp(var=NA, scale=NA) + NA * sin(R.p(new="isotropic")) + NA \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced 'repet'"); model2 <- RMexp(var=NA) + NA * sin(R.p(new="isotropic")) + NA}} print(RFfit(model2, data=dta)) ## model2 can be made explicit by enclosing the trend parts by ## 'RMtrend' model3 <- RMexp(var=NA, scale=NA) + NA * RMtrend(sin(R.p(new="isotropic"))) + RMtrend(NA) print(RFfit(model2, data=dta)) ## IMPORTANT: subtraction is not a way to combine definite models ## with trends trend <- -1 (model0 <- RMexp(var=0.4) + trend) ## exponential covariance with mean -1 (model1 <- RMexp(var=0.4) + -1) ## same as model0 (model2 <- RMexp(var=0.4) + RMtrend(-1)) ## same as model0 (model3 <- RMexp(var=0.4) - 1) ## this is a purely deterministic model ## with exponential trend plot(RFsimulate(model=model0, x=x, y=x)) ## exponential covariance ## and mean -1 plot(RFsimulate(model=model1, x=x, y=x)) ## dito plot(RFsimulate(model=model2, x=x, y=x)) ## dito plot(RFsimulate(model=model3, x=x, y=x)) ## purely deterministic model! \dontshow{\dontrun{ ################################################## # Example 1: # # Simulate from model with a plane trend surface # ################################################## #trend: 1 + x - y, cov: exponential with variance 0.01 model <- ~ RMtrend(mean=1, plane = c(1,-1)) + RMexp(var=0.04) #equivalent model: model <- ~ RMtrend(polydeg=1,polycoeff=c(1,1,-1)) + RMexp(var=0.4) #Simulation x <- 0:10 simulated0 <- RFsimulate(model=model, x=x, y=x) plot(simulated0) }} \dontshow{\dontrun{ ## PLOT SIEHT NICHT OK AUS !! #################################################################### # # Example 2: Simulate and fit a multivariate geostatistical model # #################################################################### # Simulate a bivariate Gaussian random field with trend # m_1((x,y)) = x + 2*y and m_2((x,y)) = 3*x + 4*y # where m_1 is a hyperplane describing the trend for the first response # variable and m_2 is the trend for the second one; # the covariance function is the sum of a bivariate Whittle-Matern model # and a multivariate nugget effect x <- y <- 0:10 x <- y <- seq(0, 10, 0.1) model <- RMtrend(plane=matrix(c(1,2,3,4), ncol=2)) + RMparswm(nu=c(1,1)) + RMnugget(var=0.5) multi.simulated <- RFsimulate(model=model, x=x, y=y) plot(multi.simulated) }} \dontshow{\dontrun{ # Fit the Gaussian random field with unknown trend for the second # response variable and unknown variances model.na <- RMtrend(plane=matrix(c(1, 2, NA, NA), ncol=2)) + RMparswm(nu=c(1,1), var=NA) + RMnugget(var=NA) fit <- RFfit(model=model.na, data=multi.simulated) }} \dontshow{\dontrun{ ################################################## # # Example 3: Simulation and estimation for model with # arbitrary trend functions # ################################################## #Simulation # trend: 2*sin(x) + 0.5*cos(y), cov: spherical with scale 3 model <- ~ RMtrend(arbitraryfct=function(x) sin(x), fctcoeff=2) + RMtrend(arbitraryfct=function(y) cos(y), fctcoeff=0.5) + RMspheric(scale=3) x <- seq(-4*pi, 4*pi, pi/10) simulated <- RFsimulate(model=model, x=x, y=x) plot(simulated) ################# ?? !! #Estimation, part 1 # estimate coefficients and scale model.est <- ~ RMtrend(arbitraryfct=function(x) sin(x), fctcoeff=1) + RMtrend(arbitraryfct=function(y) cos(y), fctcoeff=1) + RMspheric(scale=NA) estimated <- RFfit(model=model.est, x=x, y=x, data=simulated@data, mle.methods="ml") #Estimation # estimate coefficients and scale model.est <- ~ RMtrend(arbitraryfct=function(x) sin(x)) + RMtrend(arbitraryfct=function(y) cos(y)) + RMspheric(scale=NA) estimated <- RFfit(model=model.est, x=x, y=x, data=simulated@data, mle.methods="ml") ################################################## # # Example 4: Simulation and estimation for model with # polynomial trend # ################################################## #Simulation # trend: 2*x^2 - 3 y^2, cov: whittle-matern with nu=1,scale=0.5 model <- ~ RMtrend(arbitraryfct=function(x) 2*x^2 - 3*y^2, fctcoeff=1) + RMwhittle(nu=1, scale=0.5) # equivalent model: model <- ~ RMtrend(polydeg=2, polycoeff=c(0,0,2,0,0,-3)) x <- 0:20 simulated <- RFsimulate(model=model, x=x, y=x) plot(simulated) #Estimation # estimate nu and the trend term assuming that it is a polynomial # of degree 2 model.est <- ~ RMtrend(polydeg=2) + RMwhittle(nu=NA, scale=0.5) estimated <- RFfit(model=model.est, x=x, y=x, data=simulated@data, mle.methods="ml") }} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RPnugget.Rd0000644000176200001440000001337713437301604015432 0ustar liggesusers\name{Independent Variables} \alias{RPnugget} \alias{Nugget} \title{Method to simulate the Nugget effect} \description{ Method to simulate the Nugget effect. (Only for advanced users) } \usage{ RPnugget(phi, boxcox, tol, vdim) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated. The only possible model for \code{phi} is \command{\link{RMnugget}}.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{tol}{ points at a distance less than or equal to \code{nugget.tol} are considered as being identical. This strategy applies to the simulation method and the covariance function itself. Hence, the covariance function is only positive definite if \code{nugget.tol=0.0}. However, if the anisotropy matrix does not have full rank and \code{nugget.tol=0.0}, then the simulations are likely to be odd. The value of \code{nugget.tol} should be of order \eqn{10^{-15}}{1e-15}. Default: \code{0.0} } \item{vdim}{positive integer; the model is treated \code{vdim}-variate, \code{vdim=1} (default) corresponds to a univariate random field. Mostly, the value of \code{vdim} is set automatically. Default is that it takes the value of the submodel \code{phi}.} } \details{ \describe{ \item{General}{ This method only allows \command{\link{RMnugget}} as a submodel. } \item{Anisotropy}{ The method also allows for zonal nugget effects. Only there the argument \code{tol} becomes important. For the zonal nugget effect, the anisotropy matrix \code{Aniso} should be given in \command{\link{RMnugget}}. There, only the kernel of the matrix is important. } \item{Points close together}{ The locations at a distance less than or equal to the \link{RFoptions} \code{nugget.tol} are considered as being identical. This strategy applies to the simulation method and the covariance function itself. Hence, the covariance function is only positive definite if \code{nugget.tol=0.0}. However, if the anisotropy matrix does not have full rank and \code{nugget.tol=0.0}, then the simulations are likely to be odd. The value of \code{nugget.tol} should be of order \eqn{10^{-15}}{1e-15}. } \item{Repeated measurements}{ Measurement errors are mathematically not distinguishable from spatial nugget effects as long as measurements are not repeated at the very same space-time location. So there is no need to distinguish the spatial nugget effect from a measurement error. This is the default, see \code{allow_duplicated_locations} in \link{RFoptions}. In case several measurement have been taken in single space-time locations, measurement errors can be separated from spatial noise. In this case \code{RMnugget()} models the measurement error (which corresponds to a non-stationary model in an abstract space) by default and the measurement error model cannot be extended beyond the given locations. On the other hand \code{RMnugget(Ansio=something)} and \code{RMnugget(proj=something)} model the spatial nugget effect (with and without zonal anisotropy in case \code{Aniso} has low and full rank respectively). } \item{Role of \command{RPnugget}}{ Even for advanced users, there is no need to call \command{RPnugget} directly, as this is done internally when the \link{RMnugget} is involved in the covariance model. } } } \value{ \code{RPnugget} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. } } \me \seealso{ \link{Gaussian}, \link{RP}, \command{\link{RPcoins}}, \command{\link{RPhyperplane}}, \command{\link{RPspectral}}, \command{\link{RPtbm}}. } \keyword{methods} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## zonal nugget effect, which is not along the axes model <- RMnugget(Aniso=matrix(1, nr=2, nc=2)) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## All the following examples refer to repeated measurements RFoptions(allow_duplicated_locations = TRUE) (xy <- rbind(xy, xy)) ## now, the 4 locations are repeated twice ## standard situation: the nugget is interpreted as measurement error: model <- RMnugget() RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## any anisotropy matrix with full rank: spatial nugget effect model <- RMnugget(Aniso=diag(2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## anisotropy matrix with lower rank: zonal nugget effect model <- RMnugget(Aniso=matrix(c(1, 0, 0, 0), nc=2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## same as before: zonal nugget effect model <- RMnugget(Aniso=t(c(1,0))) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) \dontshow{FinalizeExample(); RFoptions(allow_duplicated_locations = FALSE) }}RandomFields/man/obsolete3.Rd0000644000176200001440000000477713437301604015602 0ustar liggesusers\name{Obsolete Functions Version 3} \alias{RFempiricalvariogram} \alias{RFempiricalcovariance} \alias{RFempiricalmadogram} \alias{RMstrokorbMono} \alias{RMstrokorbBall} \alias{RMstrokorbPoly} \title{Obsolete functions Version 3} \description{ Some functions of RandomFields Version 3 have been replaced by more powerful functions } \usage{ RFempiricalvariogram(...) RFempiricalcovariance(...) RFempiricalmadogram(...) } \arguments{ \item{...}{See for the recent functions given in the Details} } \details{ \describe{ \item{RFempiricalvariogram}{see \command{\link{RFvariogram}}} \item{RFempiricalcovariance}{see \command{\link{RFcov}}} \item{RFempiricalmadogram}{see \command{\link{RFmadogram}}} % \item{RFempirical} see \command{\link{RF}} % \item{RFempirical} see \command{\link{RF}} \item{Strokorb's M3/M4 functions}{are called \command{\link{RMm2r}}, \command{\link{RMm3b}}, \command{\link{RMmps}}} } } \value{ see the respective recent function } \seealso{ \command{\link{RFcov}}, \command{\link{RFcovmatrix}}, \command{\link{RFvariogram}}. \command{\link{RFpseudovariogram}}, \command{\link{RFmadogram}}, \command{\link{RFpseudomadogram}} } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again %\dontshow{RFoptions(internal.warn_newstyle=FALSE, %internal.warn_oldstyle=FALSE)} ## no examples given, as command is obsolete \dontshow{\dontrun{ # ok x <- seq(0, 5, 0.05) model <- "exp" param <- c(0, 1, 0, 1) plot(x, Covariance(x, model=model, param=param)) plot(x, Variogram(x, model=model, param=param)) z <- GaussRF(x, model=model, param=param) plot(x, z, type="l") z <- GaussRF(x=x, y=x, model=model, param=param, grid=TRUE) image(x, x, z) EmpiricalVariogram(x, x, data=z) g1 <- runif(5) * 2 g2 <- runif(5) * 2 z <- GaussRF(g1, g2, grid=FALSE, model=model, param=param) k <- Kriging("S", x, x, given=cbind(g1, g2), data=z, model=model, param=param) Print(range(z), range(k)) col <- rainbow(20) zlim <- range(z, k) image(x, x, k, col=col, zlim=zlim) points(g1, g2, pch=20,cex=2) points(g1, g2, pch=16, col=col[pmax(1, (z-zlim[1]) / diff(zlim) * 20 )]) #% farben stimmen in etwa. estparam <- rep(NA, 4) v <- fitvario(x=g1, y=g2, grid=FALSE, model=model, param=estparam, data=z) Print(v$ml, v$ml$ml.value) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMcov.Rd0000644000176200001440000000613313437301604014715 0ustar liggesusers\name{RMcov} \alias{RMcov} \alias{RMcov} \alias{RMCOV_X} \title{Non-stationary covariance model corresponding to a variogram model} \description{ This function generalizes the well-known non-stationary covariance function \eqn{2\min\{x,y\}} of the Brownian motion with variogram \eqn{\gamma(x,y) = |x-y|}, \eqn{x,y\ge 0} to arbitrary variogram models any spatial processes of any dimension and multivariability. Furthermore, the standard condition for the Brownian motion \eqn{W} is that variance equals \eqn{0} at the origin, i.e., \eqn{W(x) =^d Z(x) -Z(0)} for any zero mean Gaussian process \eqn{Z} with variogram \eqn{\gamma(x,y) = |x-y|} is replaced by \eqn{W(x) = Z(x) -\sum_{i=1}^n a_i Z(x_i)} with \eqn{\sum_{i=1}^n a_i = 1}. For a given variogram \eqn{\gamma}, \eqn{a_i} and \eqn{x_i}, the model equals \eqn{C(x, y) = \sum_{i=1}^n a_i (\gamma(x, x_i) + \gamma(x_i, y)) - \gamma(x, y) - \sum_{i=1}^n \sum_{j=1}^n a_i a_j \gamma(x_i, y_i) } } \usage{ RMcov(gamma, x, y=NULL, z=NULL, T=NULL, grid, a, var, scale, Aniso, proj, raw, norm) } \arguments{ \item{gamma}{a variogram model. Possibly multivariate.} \item{x,y,z,T,grid}{ The usual arguments as in \command{\link{RFsimulate}} to define the locations where the covariates are given. Additional \code{x} might be set to one of the values \code{"origin"}, \code{"center"}, \code{"extremals"}, or \code{"all"}. If \code{x} is not given, \code{x} is set to \code{"origin"}. } \item{a}{vector of weights. The length of \code{a} must equal the number of points given by \code{x}, \code{y}, \code{z} and \code{T}. The values of \code{a} must sum up to \eqn{1}. If \code{a} is not given, equals weights are used. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} \item{raw}{\argRaw} \item{norm}{\argNorm} } %\details{} \value{ \command{\link{RMcov}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}} } \author{Martin Schlather, \email{schlather@math.uni-mannheim.de} } \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again bm <- RMfbm(alpha=1) plot(bm) x <- seq(0, 6, if (interactive()) 0.125 else 3) plot(RFsimulate(bm, x)) ## standardizing with the random variable at the origin z1 <- RFsimulate(RMcov(bm), x) plot(z1) z1 <- as.vector(z1) zero <- which(abs(x) == 0) stopifnot(abs(z1[zero]) < 1e-13) ## standardizing with the random variable at the center of the interval z2 <- RFsimulate(RMcov(bm, "center"), x) plot(z2) z2 <- as.vector(z2) stopifnot(abs(z2[(length(z2) + 1) / 2]) < 1e-13) ## standardizing with the random variables at the end points of the interval z3 <- RFsimulate(RMcov(bm, "extremals"), x) plot(z3) z3 <- as.vector(z3) stopifnot(abs(z3[1] + z3[length(z3)]) < 1e-13) \dontshow{FinalizeExample()} }RandomFields/man/RFcov.Rd0000644000176200001440000001117413437301604014707 0ustar liggesusers\name{RFcov} \alias{RFcov} \title{(Cross-)Covariance function} \description{ Calculates both the empirical and the theoretical (cross-)covariance function. } \usage{ RFcov(model, x, y = NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{data}{\argData} \item{bin}{\argBin} \item{phi}{\argPhi} \item{theta}{\argTheta} \item{deltaT}{\argDeltaT} \item{distances,dim}{\argDistances} \item{vdim}{\argVdim} \item{...}{\argDots} } \details{ \command{\link{RFcov}} computes the empirical cross-covariance function for given (multivariate) spatial data. The empirical (cross-)covariance function of two random fields \eqn{X}{X} and \eqn{Y}{Y} is given by \deqn{\gamma(r):=\frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})Y(t_{j})) - m_{X} m_{Y}}{\gamma(r):=1/N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})Y(t_{j})) - m_{X} m_{Y}} where \eqn{t_{i,j}:=t_{i}-t_{j}}{t_{i,j}:=t_{i}-t_{j}}, \eqn{N(r)}{N(r)} denotes the number of pairs of data points with distancevector \eqn{t_{i,j}=r}{t_{i,j}=r} and where \eqn{m_{X} := \frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} X_{t_{i}}}{m_{X} := \frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} X_{t_{i}}} and \eqn{m_{Y} := \frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} Y_{t_{i}}}{m_{Y} := 1/N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} Y_{t_{i}}} denotes the mean of data points with distancevector \eqn{t_{i,j}=r}{t_{i,j}=r}. The spatial coordinates \code{x}, \code{y}, \code{z} should be vectors. For random fields of spatial dimension \eqn{d > 3} write all vectors as columns of matrix x. In this case do neither use y, nor z and write the columns in \code{gridtriple} notation. If the data is spatially located on a grid a fast algorithm based on the fast Fourier transformed (fft) will be used. As advanced option the calculation method can also be changed for grid data (see \command{\link{RFoptions}}.) It is also possible to use \command{\link{RFcov}} to calculate the pseudocovariance function (see \command{\link{RFoptions}}). } \value{ \command{\link{RFcov}} returns objects of class \command{\link[=RFempVariog-class]{RFempVariog}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \author{Jonas Auel; Sebastian Engelke; Johannes Martini; \martin} \seealso{ \command{\link{RFvariogram}}, \command{\link{RFmadogram}}, \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFcov(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFcov(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE) \dontshow{\dontrun{ ###################################################### # NOTE: distinguish the different uses of x and y x <- c(1,2,1) y <- c(4,5,6) # coordinate space 1-dimensional, evaluated at 3 points: RFcov(model=model, x=as.matrix(x), y=as.matrix(y)) # coordinate space is 3-dimensional, evaluated at a pair of points RFcov(model=model, x=t(x), y=t(y)) }} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/soil.Rd0000644000176200001440000000665313437301604014644 0ustar liggesusers\name{soil} \docType{data} \alias{soil} \title{Soil data of North Bavaria, Germany} \usage{data(soil)} \description{ Soil physical and chemical data collected on a field in the Weissenstaedter Becken, Germany } \format{ This data frame contains the following columns: \describe{ \item{x.coord}{x coordinates given in cm} \item{y.coord}{y coordinates given in cm} \item{nr}{number of the samples, which were taken in this order} \item{moisture}{moisture content [Kg/Kg * 100\%]} \item{NO3.N}{nitrate nitrogen [mg/Kg]} \item{Total.N}{total nitrogen [mg/Kg]} \item{NH4.N}{ammonium nitrogen [mg/Kg]} \item{DOC}{dissolved organic carbon [mg/Kg]} \item{N20N}{nitrous oxide [mg/Kg dried substance]} } } \details{ For technical reasons some of the data were obtained as differences of two measurements (which are not available anymore). Therefore, some of the data have negative values. } \source{ The data were collected by Wolfgang Falk, Soil Physics Group, % \url{http://www.geo.uni-bayreuth.de/bodenphysik/Welcome.html}, University of Bayreuth, Germany. } \references{ Falk, W. (2000) \emph{Kleinskalige raeumliche Variabilitaet von Lachgas und bodenchemischen Parameters [Small Scale Spatial Variability of Nitrous Oxide and Pedo-Chemical Parameters]}, Master thesis, University of Bayreuth, Germany. } \me \examples{\dontshow{StartExample()} % library("RandomFields") RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################ ## ## ## a geostatistical analysis that demonstrates ## ## features of the package 'RandomFields' ## ## ## ################################################################ data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") rm(soil) ## muss vorher entfernt werden, sonst funktioniert data(soil) ## nicht sicher data(soil) All <- 1:7 soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} ## plot the data first colour <- rainbow(100) plot(dta, col=colour) ## fit by eye gui.model <- RFgui(dta) \dontshow{if (!interactive()) gui.model <- RMexp()} %ok ## fit by ML model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) (fit <- RFfit(model, data=dta)) plot(fit, method=c("ml", "plain", "sqrt.nr", "sd.inv"), model = gui.model, col=1:8) ## Kriging ... x <- seq(min(dta@coords[, 1]), max(dta@coords[, 1]), l=121) k <- RFinterpolate(fit, x=x, y=x, data=dta) plot(x=k, col=colour) plot(x=k, y=dta, col=colour) ## what is the probability that at no point of the ## grid given by x and y the moisture is greater than 24 percent? % works well since fit$ml:nugget==0!!!! cs <- RFsimulate(model=fit@ml, x=x, y=x, data=dta, n=50) plot(cs, col=colour) plot(cs, y=dta, col=colour) Print(mean(apply(as.array(cs) <= 24, 3, all))) ## about 40 percent ... \dontshow{FinalizeExample()}} \keyword{datasets} RandomFields/man/RMparswm.Rd0000644000176200001440000000536213437301604015442 0ustar liggesusers\name{RMparswm} \alias{RMparswm} \alias{RMparswmX} \title{Parsimonious Multivariate Whittle Matern Model} \description{ \command{\link{RMparswm}} is a multivariate stationary isotropic covariance model whose corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given for \eqn{i,j \in \{1,2\}}{i,j = 1,2} by \deqn{C_{ij}(r)= c_{ij} W_{\nu_{ij}}(r).}{C_{ij}(r)=c_{ij} W_{\nu_{ij}}(r).} Here \eqn{W_\nu} is the covariance of the \command{\link{RMwhittle}} model. \command{RMparswmX} ist defined as \deqn{\rho_{ij} C_{ij}(r)} where \eqn{\rho_{ij}} is any covariance matrix. } \usage{ RMparswm(nudiag, var, scale, Aniso, proj) RMparswmX(nudiag, rho, var, scale, Aniso, proj) } \arguments{ \item{nudiag}{a vector of arbitrary length of positive values; the vector \eqn{(\nu_{11},\nu_{22},...)}. The offdiagonal elements \eqn{\nu_{ij}} are calculated as \eqn{0.5 (\nu_{ii} + \nu_{jj})}.} \item{rho}{any positive definite \eqn{m \times m}{m x m} matrix; here, \eqn{m} equals \code{length(nudiag)}. For the calculation of \eqn{c_{ij}} see Details. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified. } } \details{ In the equation above we have \deqn{c_{ij} = \rho_{ij} \sqrt{G_{ij}} }{ c_{ij} = \rho_{ ij} \sqrt G_{ij}} and \deqn{G_{ij} = \frac{\Gamma(\nu_{11} + d/2) \Gamma(\nu_{22} + d/2) \Gamma(\nu_{12})^2}{\Gamma(\nu_{11}) \Gamma(\nu_{22}) \Gamma(\nu_{12}+d/2)^2} }{ G_{ij} = \Gamma(\nu_{11} + d/2) \Gamma(\nu_{22} + d/2) \Gamma(\nu_{12}) / (\Gamma(\nu_{11}) \Gamma(\nu_{22}) \Gamma(\nu_{12}+d/2))^2)} where \eqn{\Gamma} is the Gamma function and \eqn{d} is the dimension of the space. Note that the definition of \command{RMparswmX} is \code{RMschur(M=rho, RMparswm(nudiag, var, scale, Aniso, proj))}. } \value{ \command{\link{RMparswm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T., Kleiber, W., Schlather, M. (2010) Matern covariance functions for multivariate random fields \emph{JASA} } } \me \seealso{ \command{\link{RMbiwm}}, \command{\link{RMwhittle}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again rho <- matrix(nc=3, c(1, 0.5, 0.2, 0.5, 1, 0.6, 0.2, 0.6, 1)) model <- RMparswmX(nudiag=c(1.3, 0.7, 2), rho=rho) plot(model) x.seq <- y.seq <- seq(-10, 10, 0.1) z <- RFsimulate(model = model, x=x.seq, y=y.seq) plot(z) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMtbm.Rd0000644000176200001440000000637713437301604014722 0ustar liggesusers\name{RMtbm} \alias{RMtbm} \title{Turning Bands Method} \description{ \command{\link{RMtbm}} is a univariate or multivaraiate stationary isotropic covariance model in dimension \code{reduceddim} which depends on a univariate or multivariate stationary isotropic covariance \eqn{\phi}{phi} in a bigger dimension \code{fulldim}. For formulas for the covariance function see details. } \usage{ RMtbm(phi, fulldim, reduceddim, layers, var, scale, Aniso, proj) } \arguments{ \item{phi, fulldim, reduceddim, layers}{See \command{\link{RPtbm}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMtbm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ The turning bands method stems from the 1:1 correspondence between the isotropic covariance functions of different dimensions. See Gneiting (1999) and Strokorb and Schlather (2014). The standard case is \code{reduceddim=1} and \code{fulldim=3}. If only one of the arguments is given, then the difference of the two arguments equals 2. For \code{d == n + 2}, where \code{n=reduceddim} and \code{d==fulldim} the original dimension, we have \deqn{ C(r) = \phi(r) + r \phi'(r) / n }{ C(r) = phi(r) + r phi'(r) / n } which for \code{n=1} reduces to the standard TBM operator \deqn{ C(r) =\frac {d}{d r} r \phi(r) }{ C(r) = d/dr [ r phi(r) ] } For \code{d == 2 && n == 1} we have \deqn{ C(r) = \frac{d}{dr}\int_0^r \frac{u\phi(u)}{\sqrt{r^2 - u^2}} d u }{ C(r) = d/dr int_0^r [ r phi(r) ] / [ sqrt{r^2 - u^2} ] d u } \sQuote{Turning layers} is a generalization of the turning bands method, see Schlather (2011). } \references{ Turning bands \itemize{ \item Gneiting, T. (1999) On the derivatives of radial positive definite function. \emph{J. Math. Anal. Appl}, \bold{236}, 86-99 \item Matheron, G. (1973). The intrinsic random functions and their applications. \emph{Adv . Appl. Probab.}, \bold{5}, 439-468. \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } Turning layers \itemize{ \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. } } \seealso{ \command{\link{RPtbm}}, \command{\link{RFsimulate}}. } \me \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.02) model <- RMspheric() plot(model, model.on.the.line=RMtbm(RMspheric()), xlim=c(-1.5, 1.5)) z <- RFsimulate(RPtbm(model), x, x) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMbicauchy.Rd0000644000176200001440000000303613437301604015714 0ustar liggesusers\name{RMbicauchy} \alias{RMbicauchy} \title{Bivariate Cauchy Model} \description{ \command{\link{RMbicauchy}} is a bivariate stationary isotropic covariance model whose corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points. % and is given for \eqn{i,j \in \{1,2\}}{i,j = 1,2} by % \deqn{C_{ij}(r)=[to be done].} For constraints on the constants see Details. } \usage{ RMbicauchy(alpha, beta, s, rho, var, scale, Aniso, proj) } \arguments{ \item{alpha}{[to be done]} \item{beta}{[to be done]} \item{s}{a vector of length 3 of numerical values; each entry positive; the vector \eqn{(s_{11},s_{21},s_{22})}} \item{rho}{[to be done] } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Constraints on the constants: [to be done] } \value{ \command{\link{RMbicauchy}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Moreva, O., Schlather, M. (2016) Modelling and simulation of bivariate Gaussian random fields. \emph{arXiv 1412.1914} } } \me \seealso{ \command{\link{RMcauchy}}, \link{Multivariate RMmodels}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo \dontshow{FinalizeExample()} }RandomFields/man/RPcoin.Rd0000644000176200001440000000540713437301604015064 0ustar liggesusers\name{Coins} \alias{Coins} \alias{RPcoins} \alias{Average} \alias{RPaverage} \title{Random coin method} \description{ The random coin method (or dilution method) is a simulation method for stationary Gaussian random fields. It is based on the following procedure: For a stationary Poisson point process on \eqn{{\bf R}^d}{R^d} consider the random field \deqn{Y(y) = \sum_{x\in X} f(y-x)}{Y(y) = \sum_{x\in X} f(y-x)} for a function \eqn{f}{f}. The covariance of \eqn{Y}{Y} is proportional to the convolution \deqn{C(h) = \int f(x)f(x+h) dx }{C(h) = \int f(x)f(x+h) dx} If the intensity of the Poisson point process increases, the random field \eqn{Y}{Y} approaches a Gaussian random field with covariance function \eqn{C}{C}. } \usage{ RPcoins(phi, shape, boxcox, intensity, method) RPaverage(phi, shape, boxcox, intensity, method) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance function of the Poisson process; either \code{phi} or \code{shape} must be given. } \item{shape}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the function which is attached to the Poisson points; note that this is not the covariance function of the simulated random field.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{intensity}{positive number, intensity of the underlying Poisson point process. } \item{method}{integer. Default is the value \code{0} which addresses the current standard procedure. There might be further methods implemented mainly for internal purposes. } } %\details{} \value{ \command{\link{RPcoins}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Lantuejoul, C. (2002) \emph{Geostatistical Simulation: Models and Algorithms.} Springer. }} \me \seealso{ \link{Gaussian}, \link{RP}, \command{\link{RPhyperplane}}, \command{\link{RPspectral}}, \command{\link{RPtbm}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ x <- seq(0,25, 0.02) model <- RPcoins(RMspheric()) z <- RFsimulate(model, x, x, spConform=FALSE) # takes 20 sec Print(sd(as.vector(z)), mean(z)) image(z) ### Gaussian field approximated by Poisson fields x <- seq(0,10, 0.02) for (intensity in c(1, 10, 100)) { z <- RFsimulate(x=x, model=RPcoins(RMspheric(), intensity = intensity)) plot(z) } }} \dontshow{FinalizeExample()}} \keyword{methods} RandomFields/man/RRloc.Rd0000644000176200001440000000235013437301604014705 0ustar liggesusers\name{RRloc} \alias{RRloc} \title{Location and Scale Modification of A Distribution} \description{ \command{RRloc} modifies location and scale of a distribution. } \usage{ RRloc(phi, mu, scale, pow) } \arguments{ \item{phi}{distribution \command{\link{RMmodel}}} \item{mu}{location shift} \item{scale}{scale modification} \item{pow}{argument for internal use only} % } \value{ \command{\link{RRloc}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ It has the same effect as \code{\link{RRdistr}(\link{norm}(mu=mu, sd=sd, log=log))} } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RRdistr}}, \command{\link{RRgauss}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## empirical density of the distribution 'RRspheric' model <- RRspheric(balldim=2) hist(RFrdistr(model, n=1000), 50) ## empirical density of the distribution 'RRspheric', shifted by 3 model <- RRloc(mu=3, RRspheric(balldim=2)) hist(RFrdistr(model, n=1000), 50) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RPspectral.Rd0000644000176200001440000000635513437301604015754 0ustar liggesusers\name{Spectral} \alias{Spectral} \alias{RPspectral} \title{Spectral turning bands method} \description{The spectral turning bands method is a simulation method for stationary Gaussian random fields (Mantoglou and Wilson, 1982). It makes use of Bochners's theorem and the corresponding spectral measure \eqn{\Xi}{\Xi} for a given covariance function \eqn{C(h)}. For \eqn{x \in {\bf R}^d}{x in R^d}, the field \deqn{Y(x)= \sqrt{2} cos( + 2 \pi U)}{Y(x)=\sqrt{2} cos( + 2 pi U)} with \eqn{V ~ \Xi } and \eqn{U ~ Ufo((0,1))} is a random field with covariance function \eqn{C(h)}. A scaled superposition of many independent realizations of \eqn{Y}{Y} gives a Gaussian field according to the central limit theorem. For details see Lantuejoul (2002). The standard method allows for the simulation of 2-dimensional random fields defined on arbitrary points or arbitrary grids. } \usage{ RPspectral(phi, boxcox, sp_lines, sp_grid, prop_factor, sigma) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated.} % \item{loggauss}{see \command{\link{RPgauss}}.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{sp_lines}{ Number of lines used (in total for all additive components of the covariance function). Default: \code{2500}. } \item{sp_grid}{Logical. The angle of the lines is random if \code{grid=FALSE}, and \eqn{k\pi/}\code{sp_lines} for \eqn{k}{k} in \code{1:sp_lines}, otherwise. This argument is only considered if the spectral measure, not the density is used. Default: \code{TRUE}. } \item{prop_factor}{ % to do: use RRrectangular positive real value. Sometimes, the spectral density must be sampled by MCMC. Let \eqn{p} be the average rejection rate. Then the chain is sampled every \eqn{n}th point where \eqn{n = |log(p)| *}\code{prop_factor}. Default: \code{50}. } \item{sigma}{real. Considered if the Metropolis algorithm is used. It gives the standard deviation of the multivariate normal distribution of the proposing distribution. If \code{sigma} is not positive then \code{RandomFields} tries to find a good choice for \code{sigma} itself. Default: \code{0}. } } \value{ \code{RPspectral} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Lantuejoul, C. (2002) \emph{Geostatistical Simulation: Models and Algorithms.} Springer. \item Mantoglou, A. and J. L. Wilson (1982), \emph{The Turning Bands Method for simulation of random fields using line generation by a spectral method.} Water Resour. Res., 18(5), 1379-1394. }} \me \seealso{\link{Gaussian}, \link{RP}, \command{\link{RPtbm}}. } \keyword{methods} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPspectral(RMmatern(nu=1)) y <- x <- seq(0,10, len=400) z <- RFsimulate(model, x, y, n=2) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RRspherical.Rd0000644000176200001440000000205513437301604016104 0ustar liggesusers\name{RRspheric} \alias{RRspheric} \title{Random scaling used with balls} \description{ This model delivers the distribution of the \bold{radius} of a ball obtained by the intersection of a \code{balldim}-dimensional ball with \bold{diameter} R by a \eqn{spacedim}-dimensional hyperplane that has uniform distance from the center. } \usage{ RRspheric(spacedim, balldim, R) } \arguments{ \item{spacedim}{dimension of the hyperplane; defaults to 1.} \item{balldim}{the dimension of the ball} \item{R}{radius. Default: 1.} } \value{ \command{\link{RRspheric}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMball}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again hist(RFrdistr(RRspheric(balldim=2), n=1000), 50) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RPhyperplane.Rd0000644000176200001440000000503113437301604016274 0ustar liggesusers\name{Hyperplane} \alias{Hyperplane} \alias{Hyperplanes} \alias{RPhyperplane} \title{Hyperplane method} \description{ The Hyperplane method is a simulation method for stationary, isotropic random fields with exponential covariance function. It is based on a tessellation of the space by hyperplanes. Each cell takes a spatially constant value of an i.i.d. random variable. The superposition of several such random fields yields approximatively a Gaussian random field. } \usage{ RPhyperplane(phi, boxcox, superpos, maxlines, mar_distr, mar_param ,additive) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance function to be simulated; only exponential covariance functions and scale mixtures of it are allowed. } % \item{loggauss}{see \command{\link{RPgauss}}.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{superpos}{integer. number of superposed hyperplane tessellations. Default: \code{300}.} \item{maxlines}{integer. Maximum number of allowed lines. Default: \code{1000}. } \item{mar_distr}{integer. code for the marginal distribution used in the simulation: \describe{ \item{\code{0}}{uniform distribution} \item{\code{1}}{Frechet distribution with form parameter \code{mar_param}} \item{\code{2}}{Bernoulli distribution (Binomial with \eqn{n=1}) with argument \code{mar_param}} } This argument should not be changed yet. Default: \code{0}. } \item{mar_param}{Argument used for the marginal distribution. The argument should not be changed yet. Default: \code{NA}. } \item{additive}{logical. If \code{TRUE} independent realizations are added, else the maximum is taken. Default: \code{TRUE}. } } \value{ \code{RPhyperplane} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Lantuejoul, C. (2002) \emph{Geostatistical Simulation: Models and Algorithms.} Springer. } } \me \seealso{ \link{Gaussian}, \link{RP}. } \keyword{methods} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPhyperplane(RMexp(s=2), superpos=1) x <- seq(0, 3, 0.04) z <- RFsimulate(x=x, x, model=model, n=1) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMbr2eg.Rd0000644000176200001440000000460013437301604015124 0ustar liggesusers\name{RMbr2eg} \alias{RMbr2eg} \title{Transformation from Brown-Resnick to Gauss} \description{ This function can be used to model a max-stable process based on a binary field, with the same extremal correlation function as a Brown-Resnick process \deqn{ C_{eg}(h) = 1 - 2 (1 - 2 \Phi(\sqrt{\gamma(h) / 2}) )^2 } Here, \eqn{\Phi} is the standard normal distribution function, and \eqn{\gamma} is a \bold{semi-}variogram with sill \deqn{ 4(erf^{-1}(1/\sqrt 2))^2 = 2 * [\Phi^{-1}( [1 + 1/\sqrt 2] / 2)]^2 = 4.425098 / 2 = 2.212549} } \usage{ RMbr2eg(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ object of class \code{\link[=RMmodel-class]{RMmodel}} } \details{ \command{\link{RMbr2eg}} \cr The extremal Gaussian model \command{\link{RPschlather}} simulated with \code{\link{RMbr2eg}(\link{RMmodel}())} has tail correlation function that equals the tail correlation function of Brown-Resnick process with variogram \command{\link{RMmodel}}. Note that the reference paper is based on the notion of the (genuine) variogram, whereas the package \pkg{RandomFields} is based on the notion of semi-variogram. So formulae differ by factor 2. } \references{ \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \seealso{ \link{maxstableAdvanced}, \command{\link{RMbr2bg}}, \command{\link{RMmodel}}, \command{\link{RMm2r}}, \command{\link{RPbernoulli}}, \command{\link{RPbrownresnick}}, \command{\link{RPschlather}}. } \me \keyword{spatial} \examples{\dontshow{StartExample(reduced=20)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) binary.model <- RPbernoulli(RMbr2bg(model)) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(binary.model), x, x) plot(z) \dontshow{FinalizeExample()}}RandomFields/man/RPpoisson.Rd0000644000176200001440000000264013437301604015622 0ustar liggesusers\name{RPpoisson} \alias{RPpoisson} \title{Simulation of Poisson Random Fields} \description{ Shot noise model, which is also called moving average model, trigger process, dilution random field, and by several other names. } \usage{ RPpoisson(phi, intensity) } \arguments{ \item{phi}{the model, \command{\link{RMmodel}}, gives the shape function to be used} \item{intensity}{the intensity of the underlying stationary Poisson point process } } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # example 1: Posson field based on disks with radius 1 x <- seq(0,25, 0.02) model <- RMball() z <- RFsimulate(RPpoisson(model), x, intensity = 2) plot(z) par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1], breaks=0.5 + (-1 : max(z@data))) # example 2: Poisson field based on the normal density function # note that # (i) the normal density as unbounded support that has to be truncated # (ii) the intensity is high so that the CLT holds x <- seq(0, 10, 0.01) model <- RMtruncsupport(radius=5, RMgauss()) z <- RFsimulate(RPpoisson(model), x, intensity = 100) plot(z) \dontshow{FinalizeExample()}} \seealso{ \command{\link{RMmodel}}, \link{RP}, \command{\link{RPcoins}}. } \keyword{spatial} RandomFields/man/RMintexp.Rd0000644000176200001440000000275313437301604015441 0ustar liggesusers\name{RMintexp} \alias{RMintexp} \title{Integral exponential operator} \description{ \command{\link{RMintexp}} is a univariate stationary covariance model depending on a univariate variogram model \eqn{\phi}{phi}. The corresponding covariance function only depends on the difference \eqn{h}{h} between two points and is given by \deqn{C(h)=(1 - exp(-\phi(h)))/\phi(h)}{C(h)=(1 - exp(-phi(h)))/phi(h)}} \usage{ RMintexp(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{a variogram \command{\link{RMmodel}}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } %\details{} \value{ \command{\link{RMintexp}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. \emph{Lecture Notes in Statistics, Proceedings}, \bold{207}, 25--54. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMintexp(RMfbm(alpha=1.5, scale=0.2)) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMtrafo.Rd0000644000176200001440000001027213574017204015242 0ustar liggesusers\name{RMtrafo} \alias{RMtrafo} \alias{RFearth2cartesian} \alias{RFearth2dist} \title{Transformation of coordinate systems} \description{ The functions transform a coordinate system into another coordinate system. Currently, essentially only from the earth system to cartesian. \command{RMtrafo} is the internal basic function that also allows to reduce vectors to their norm. } \usage{ % to do: auch fuer die 'plane' transformationen RMtrafo(phi, new) RFearth2cartesian(coord, units=NULL, system="cartesian", grid=FALSE) RFearth2dist(coord, units=NULL, system="cartesian", grid=FALSE, ...) } \arguments{ \item{new}{integer or character. One of the values \code{\link[=constants]{RC_ISOTROPIC}}, \code{\link[=constants]{RC_SPACEISOTROPIC}}, % ZEROSPACEISO, % VECTORISOTROPIC, % SYMMETRIC, \code{\link[=constants]{RC_CARTESIAN_COORD}}, \code{\link[=constants]{RC_GNOMONIC_PROJ}}, \code{\link[=constants]{RC_ORTHOGRAPHIC_PROJ}} % EARTH_COORD, % SPHERICAL_COORD, % CYLINDER_COORD or the corresponding \code{\link[=constants]{RC_ISONAMES}}. Note that \command{RMtrafo} only allows for integer values. Default: \code{RC_CARTESIAN_COORD}. } \item{phi}{optional submodel} \item{coord}{matrix or vector of earth coordinates} \item{units}{"km" or "miles"; if not given and \code{RFoptions()$general$units != ""}, the latter is used. Otherwise \code{"km"}. } \item{system}{integer or character. The coordinate system, e.g. \code{"cartesian"}, \code{"gnomonic"} or \code{"orthographic"}. } \item{grid}{logical. Whether the given coordinates are considered to be on a grid given by \code{c(start, step, length)}. Default: \code{FALSE}. } \item{...}{the optional arguments of \command{\link[stats]{dist}} } } \details{ The functions transform between different coordinate systems. } \value{ The function \command{RMtrafo} returns a matrix, in general. For fixed column, the results, applied to each row of the matrix, are returned. The function \command{RFearth2cartesian} returns a matrix in one-to-one correspondence with \code{coord} assuming that the earth is an ellipsoid. The function \command{RFearth2dist} calculates distances, cf. \command{\link[stats]{dist}}, assuming that the earth is an ellipsoid. } \references{ For calculating the earth coordinates as ellipsoid: \itemize{ \item \url{https://en.wikipedia.org/wiki/Geographic_coordinate_system} \item \url{https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html} } } \note{ Important options are \code{units} and \code{coordinate_system}, see \command{\link{RFoptions}}. Note also that the zenit must be given explicitly for projection onto a plane. See the examples below. } \me \seealso{ \link{constants}, \command{\link{RMangle}}, \command{\link{RMid}}, \command{\link{RMidmodel}}. } \examples{\dontshow{StartExample()} data(weather) (coord <- weather[1:5, 3:4]) (z <- RFfctn(RMtrafo(new=RC_CARTESIAN_COORD), coord)) (z1 <- RFearth2cartesian(coord)) ## equals z z1 - z ## 0, i.e., z1 and t(z) are the same dist(z) (d <- RFearth2dist(coord)) d - dist(z) ## 0, i.e., d and dist(z) are the same ## projection onto planes RFoptions(zenit=c(-122, 47)) RFearth2cartesian(coord, system="gnomonic") RFearth2cartesian(coord, system="orthographic") \dontshow{\dontrun{ # OK ## RFearth2dist is more precise !!! library("fields") (system.time(z2 <- rdist.earth(coord, miles=FALSE))) z2 (z2 - as.matrix(d)) / z2 * 100 ## RFearth2dist is more precise # n <- 10000 system.time(for (i in 1:n) d <- RFearth2dist (coord))) ## the same as dist(t(z)) system.time(for (i in 1:n)z2 <- rdist.earth(xx))) data(weather) xx <- matrix(weather[, 3:4], ncol=2) [ 1:5, ] xx <- weather[, 3:4][ 1:5, ] Print(xx) Print(yy <- RFfctn(RMtrafo(new=RC_CARTESIAN_COORD), xx), units="miles") (z1 <- as.matrix(dist(t(yy)))) library(fields) (z2 <- rdist.earth(xx)) (z1-z2) / z1 * 100 z1 }} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMcauchy.Rd0000644000176200001440000000510113437301604015374 0ustar liggesusers\name{RMcauchy} \alias{RMcauchy} \title{Cauchy Family Covariance Model} \description{ \command{\link{RMcauchy}} is a stationary isotropic covariance model belonging to the Cauchy family. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (1 + r^2)^(-\gamma)}{C(r) = (1 + r^2)^(-\gamma)} where \eqn{\gamma > 0}{\gamma > 0}. See also \command{\link{RMgencauchy}}. } \usage{ RMcauchy(gamma, var, scale, Aniso, proj) } \arguments{ \item{gamma}{a numerical value; should be positive to provide a valid covariance function for a random field of any dimension.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The paramater \eqn{\gamma}{\gamma} determines the asymptotic power law. The smaller \eqn{\gamma}{\gamma}, the longer the long-range dependence. The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly. Each covariance function of the Cauchy Family is a normal scale mixture. The generalized Cauchy Family (see \command{\link{RMgencauchy}}) includes this family for the choice \eqn{\alpha = 2}{\alpha = 2} and \eqn{\beta = 2 \gamma}{\beta = 2 \gamma}. The generalized Hyperbolic Family (see \command{\link{RMhyperbolic}}) includes this family for the choice \eqn{\xi = 0}{\xi = 0} and \eqn{\gamma = -\nu/2}{\gamma = -\nu/2}; in this case scale=\eqn{\delta}{\delta}. } \value{ \command{\link{RMcauchy}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. } } \me \seealso{ \command{\link{RMcauchytbm}}, \command{\link{RMgencauchy}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchy(gamma=1) x <- seq(0, 10, 0.02) plot(model, xlim=c(-3, 3)) plot(RFsimulate(model, x=x, n=4)) \dontshow{FinalizeExample()}}RandomFields/man/RMave.Rd0000644000176200001440000000640113437301604014677 0ustar liggesusers\name{RMave} \alias{RMave} \title{Space-time moving average model} \description{ \command{\link{RMave}} is a univariate stationary covariance model which depends on a normal scale mixture covariance model \eqn{phi}. The corresponding covariance function only depends on the difference \eqn{(h,u) \in {\bf R}^{d}}{} between two points in the \eqn{d}-dimensional space and is given by \deqn{C(h, u) = |E + 2Ahh^tA|^{-1/2} \phi(\sqrt(\|h\|^2/ 2 + (z^th + u)^2 (1 - 2h^tA (E+2Ahh^tA)^{-1} Ah)))}{ C(h, u) = |E + 2 A h h^t A|^{-1/2} phi(sqrt[|h|^2/2 + (z^t h + u)^2 (1 - 2h^t A (E + 2 A h h^t A)^{-1} A h)])} where \eqn{E} is the identity matrix. The spatial dimension is \eqn{d-1} and \eqn{h} is real-valued. } \usage{ RMave(phi, A, z, spacetime, var, scale, Aniso, proj) } \arguments{ \item{phi}{a covariance model which is a normal mixture, that means an \command{\link{RMmodel}} whose \code{monotone} property equals \code{'normal mixture'}, see \code{\link{RFgetModelNames}(monotone="normal mixture")} } \item{A}{a symmetric \eqn{d-1 \times d-1}{d-1 x d-1}-matrix if the corresponding random field is in the \eqn{d}{d}-dimensional space} \item{z}{a \eqn{d-1} dimensional vector if the corresponding random field is on \eqn{d}-dimensional space} \item{spacetime}{logical. If FALSE then the model is interpreted as if \eqn{h=0}, i.e. the spatial dimension is \eqn{d}. Default is \code{TRUE}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{See Schlather, M. (2010), Example 13 with l=1. } \value{ \command{\link{RMave}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}} } \references{ \itemize{ \item Schlather, M. (2010) Some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RFfit}}, \command{\link{RFsimulate}}, \code{\link{RMmodel}}, \code{\link{RMstp}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example of an evaluation of the ave2-covariance function ## in three different ways ## --------------------------------------------------------- ## some parameters A and z A <- matrix(c(2,1,1,2),ncol=2) z <- c(1,2) ## h for evalutation h <- c(1,2) ## some abbreviations E <- matrix(c(1,0,0,1),ncol=2) B <- A \%*\% h \%*\% t(h) \%*\% A phi <- function(t){return(RFcov(RMwhittle(1), t))} ## --------------------------------------------------------- ## the following should yield the same value 3 times ## (also for other choices of A,z and h) z1 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z) , x=t(c(h,0)) ) z2 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z,spacetime=FALSE) , x=t(h) ) z3 <- ( (det(E+2*B))^(-1/2) ) * phi( sqrt( sum(h*h)/2 + (t(z) \%*\% h)^2 * ( 1-2*t(h) \%*\% A \%*\% solve(E+2*B) \%*\% A \%*\% h) ) ) ## \dontshow{if(maintainers.machine())stopifnot(abs(z1-z2)<1e-12,abs(z2-z3)<1e-12)} \dontrun{ stopifnot(abs(z1-z2)<1e-12, abs(z2-z3)<1e-12) } \dontshow{FinalizeExample()}} RandomFields/man/RPsequential.Rd0000644000176200001440000000575513437301604016314 0ustar liggesusers\name{Sequential} \alias{Sequential} \alias{RPsequential} \title{Methods relying on square roots of the covariance matrix} \description{ Sequential method relying on square roots of the covariance matrix } \usage{ RPsequential(phi, boxcox, back_steps, initial) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{back_steps}{ Number of previous instances on which the algorithm should condition. If less than one then the number of previous instances equals \code{max} / (number of spatial points). Default: \code{10}. } \item{initial}{ First, N=(number of spatial points) * \code{back_steps} number of points are simulated. Then, sequentially, all spatial points for the next time instance are simulated at once, based on the previous \code{back_steps} instances. The distribution of the first N points is the correct distribution, but differs, in general, from the distribution of the sequentially simulated variables. We prefer here to have the same distribution all over (although only approximatively the correct one), hence do some initial sequential steps first. If \code{initial} is non-negative, then \code{initial} first steps are performed. If \code{initial} is negative, then \code{back_steps} - \code{initial} initial steps are performed. The latter ensures that none of the very first N variables are returned. Default: \code{-10}. } } \details{ \command{RPsequential} is programmed for spatio-temporal models where the field is modelled sequentially in the time direction conditioned on the previous \eqn{k} instances. For \eqn{k=5} the method has its limits for about 1000 spatial points. It is an approximative method. The larger \eqn{k} the better. It also works for certain grids where the last dimension should contain the highest number of grid points. } \value{ \command{\link{RPsequential}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. }} \me \seealso{ \link{Gaussian}, \link{RP}, \link{RPdirect}. } \keyword{methods} \examples{\dontshow{StartExample(reduced=FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPsequential(model), 0:10, 0:10, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/macros/0000755000176200001440000000000013437301604014661 5ustar liggesusersRandomFields/man/macros/allg_defn.Rd0000644000176200001440000000062613437301604017067 0ustar liggesusers\newcommand{\martin}{Martin Schlather, \email{schlather@math.uni-mannheim.de}, \url{http://ms.math.uni-mannheim.de}} \newcommand{\marco}{Marco Oesting, \email{oesting@mathematik.uni-siegen.de}, \url{https://www.uni-siegen.de/fb6/src/scheffler/mitarbeiter/oesting}} \newcommand{\me}{\author{\martin}} \newcommand{\RFU}{See \link[RandomFieldsUtils]{RFoptions}} % library(RandomFieldsUtils); ?RFoptionsRandomFields/man/macros/defn.Rd0000644000176200001440000000021713437301604016064 0ustar liggesusers\newcommand{\Examples}{\examples{\dontshow{StartExample()}RFoptions(seed=0)#1\dontshow{FinalizeExample()}}} \newcommand{\me}{\author{\martin}} RandomFields/man/macros/def.Rd0000644000176200001440000001502713437301604015713 0ustar liggesusers% M-x auto-fill-mode \newcommand{\Examples}{\examples{\dontshow{StartExample()}RFoptions(seed=0)#1\dontshow{FinalizeExample()}}} \newcommand{\me}{\author{\martin}} \newcommand{\argModel}{ object of class \code{\link[=RMmodel-class]{RMmodel}}, \command{\link{RFformula}} or \command{\link[stats]{formula}}; best is to consider the examples below, first. \cr The argument \code{params} is a list that specifies free parameters in a formula description, see \link{RMformula}.} \newcommand{\argX}{vector of x coordinates, or object of class \code{\link[sp:GridTopology-class]{GridTopology}} or \code{\link[raster]{raster}}; for more options see \link{RFsimulateAdvanced}.} \newcommand{\argYz}{optional vectors of y (z) coordinates, which should not be given if \code{x} is a matrix.} \newcommand{\argT}{optional vector of time coordinates, \code{T} must always be an equidistant vector. Instead of \code{T=seq(from=From, by=By, len=Len)}, one may also write \code{T=c(From, By, Len)}.} \newcommand{\argGrid}{logical; the function finds itself the correct value in nearly all cases, so that usually \code{grid} need not be given. See also \link{RFsimulateAdvanced}.} \newcommand{\argData}{matrix, data.frame or object of class \command{\link[=RFsp-class]{RFsp}}; \cr If a matrix is given the ordering of the colums is the following: space, time, multivariate, repetitions, i.e. the index for the space runs the fastest and that for repetitions the slowest.} \newcommand{\argBin}{a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned.} \newcommand{\argPhi}{an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified).} \newcommand{\argTheta}{an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension \eqn{d=3}{d=3} if phi is already specified.} \newcommand{\argDeltaT}{vector of length 2, specifying the temporal bins. The internal bin vector becomes \code{seq(from=0, to=deltaT[1], by=deltaT[2])}} \newcommand{\argDistances}{another alternative for the argument \code{x} to pass the (relative) coordinates, see \link{RFsimulateAdvanced}.} \newcommand{\argVdim}{the number of variables of a multivariate data set. If not given and \code{data} is an \code{RFsp} object created by \pkg{RandomFields}, the information there is taken from there. Otherwise \code{vdim} is assumed to be one. NOTE: still the argument \code{vdim} is an experimental stage.} % to do \newcommand{\argDots}{for advanced use: further options and control arguments for the simulation that are passed to and processed by \command{\link{RFoptions}}. If \code{params} is given, then \code{...} may include also the variables used in \code{params}.} \newcommand{\argLower}{list or vector. Lower bounds for the parameters. If \code{lower} is a vector, \code{lower} has to be a vector as well and its length must equal the number of parameters to be estimated. The order of \code{lower} has to be maintained. A component being \code{NA} means that no manual lower bound for the corresponding parameter is set. \cr If \code{lower} is a list, \code{lower} has to be of (exactly) the same structure of the model.} \newcommand{\argUpper}{list or vector. Upper bounds for the parameters. See \code{lower}.} \newcommand{\argUsersguess}{ User's guess of the parameters. All the parameters must be given using the same rules as for \code{lower} (except that no NA's should be contained).} \newcommand{\argTransform}{obsolete for users; use \code{param} instead. \code{transform=list()} will return structural information to set up the correct function.} \newcommand{\argOptimcontrol}{control list for \command{\link[stats]{optim}}, which uses \sQuote{L-BFGS-B}. However \code{parscale} may not be given.} \newcommand{\argGiven}{optional, matrix or list. If \code{given} matrix then the coordinates can be given separately, namely by \code{given} where, in each row, a single location is given.\cr If \code{given} is a list, it may consist of \code{x}, \code{y}, \code{z}, \code{T}, \code{grid}.\cr If \code{given} is provided, \code{data} must be a matrix or an array containing the data only. } \newcommand{\argDataGiven}{ If \code{given} is not given and \code{data} is a matrix or \code{data} is a data.frame, \pkg{RandomFields} tries to identify where the data and the coordinates are, e.g. by names in formulae or by fixed names, see \link{Coordinate systems}. See also \link{RFsimulateAdvanced}. If all fails, the first columns are interpreted as coordinate vectors, and the last column(s) as (multiple) measurement(s) of the field. Notes that also lists of data can be passed.} \newcommand{\argErrmodel}{In case of (assumed) error-free measurements (which is mostly the case in geostatistics) the argument \code{err.model} is not given. In case of measurement errors we have \code{err.model=RMnugget(var=var)}.\cr \code{err.param} plays the same role as \code{params} for \code{model}.} \newcommand{\argFitmethods}{ Main methods to be used for estimating. If several methods are given, estimation will be performed with each method and the results reported.} \newcommand{\argFitsubmethods}{variants of the least squares fit of the variogram. variants of the maximum likelihood fit of the covariance function.} \newcommand{\argOrigin}{character; one of \code{"original"}, \code{"MLE conform"}, \code{"all"}. This argument determines the parameters that are returned.} \newcommand{\argRaw}{ logical. If \code{FALSE} then the data are interpolated. This approach is always save, but might be slow. If \code{TRUE} then the data may be accessed when covariance matrices are calculated. No rescaling or anisotropy definition is allowed in combination with the model. The use is dangerous, but fast.\cr Default: \code{FALSE}. } \newcommand{\argNorm}{optional model that gives the norm between locations} \newcommand{\GEV}{The argument \code{xi} is always a number, i.e. \eqn{\xi} is constant in space. In contrast, \eqn{\mu} and \eqn{s} might be constant numerical values or (in future!) be given by an \code{\link{RMmodel}}, in particular by an \code{\link{RMtrend}} model. \cr For \eqn{xi=0}, the default values of \eqn{mu} and \eqn{s} are \eqn{0} and \eqn{1}, respectively. For \eqn{xi\not=0}, the default values of \eqn{mu} and \eqn{s} are \eqn{1} and \eqn{|\xi|}, respectively, so that it defaults to the standard Frechet case if \eqn{\xi > 0}.} % \newcommand{\arg}{ } RandomFields/man/macros/lit.Rd0000644000176200001440000000075113437301604015743 0ustar liggesusers% M-x auto-fill-mode \newcommand{\litIntro}{Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.} \newcommand{\litLantue}{ Lantuejoul, Ch. (2002) \emph{Geostatistical simulation.} \bold{New York:} Springer.} \newcommand{\lit}{} \newcommand{\lit}{} \newcommand{\lit}{} \newcommand{\lit}{} \newcommand{\lit}{} \newcommand{\lit}{} RandomFields/man/RFboxcox.Rd0000644000176200001440000000736113437301604015425 0ustar liggesusers\name{RFboxcox} \alias{RFboxcox} \title{Linear part of \command{\link{RMmodel}}} \description{ \command{\link{RFboxcox}} performs the Box-Cox transformation: \eqn{\frac{(x+\mu)^\lambda-1}{\lambda}} } \usage{ RFboxcox(data, boxcox, vdim = 1, inverse=FALSE, ignore.na=FALSE) } \arguments{ \item{data}{matrix or list of matrices. } \item{boxcox}{the one or two parameters \eqn{(\lambda, \mu)} of the box cox transformation, in the univariate case; if \eqn{\mu} is not given, then \eqn{\mu} is set to \eqn{0}. If not given, the globally defined parameters are used, see Details. In the \eqn{m}-variate case \code{boxcox} should be a \eqn{2 \times m} matrix. If \eqn{\lambda =\infty} then no transformation is performed. } \item{vdim}{the multivariate dimensionality of the field; } \item{inverse}{logical. Whether the inverse transformation should be performed. } \item{ignore.na}{logical. If \code{FALSE} an error message is returned if any value of \code{boxcox} is \code{NA}. Otherwise the data are returned without being transformed. } } \details{ The Box-Cox transfomation \code{boxcox} can be set globally through \command{\link{RFoptions}}. If it is set globally the transformation applies in the \bold{Gaussian} case to \command{\link{RFfit}}, \command{\link{RFsimulate}}, \command{\link{RFinterpolate}}, \command{\link{RFvariogram}}. Always first, the Box-Cox transformation is applied to the data. Then the command is performed. The result is back-transformed before returned. If the first value of the transformation is \code{Inf} no transformation is performed (and is identical to \code{boxcox = c(1,0)}). If \code{boxcox} has length 1, then the transformation parameter \eqn{\mu} is set to \eqn{0}, which is the standard case. } \value{ \command{\link{RFboxcox}} returns a list of three components, \code{Y}, \code{X}, \code{vdim} returning the deterministic trend, the design matrix, and the multivariability, respectively. If \code{set} is positive, \code{Y} and \code{X} contain the values for the \code{set}-th set of coordinates. Else, \code{Y} and \code{X} are both lists containing the values for all the sets. } \me \seealso{ \link{Bayesian}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFlikelihood}}. } \references{ For the likelihood correction see \itemize{ \item Konishi, S., and Kitagawa, G. (2008) \emph{Information criteria and statistical modeling.} Springer Science & Business Media. Section 4.9. } } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") All <- 1:7 rm(soil) data(soil) soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} model <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=NA)) \dontshow{\dontrun{ ## Assuming log-Gaussian Data print(fit <- RFfit(model, data=dta, loggaus=TRUE)) }} ## main Parameter in the Box Cox transformation to be estimated print(fit <- RFfit(model, data=dta, boxcox=NA)) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMmodelsAdvanced.Rd0000644000176200001440000002221213437301604017033 0ustar liggesusers\name{RMmodelsAdvanced} \alias{RMmodelsAdvanced} \alias{Advanced RMmodels} \title{Advanced features of the models} \description{ Here, further models and advanced comments for \command{\link{RMmodel}} are given. See also \command{\link{RFgetModelNames}}. } \details{ \bold{Further stationary and isotropic models} \tabular{ll}{ \command{\link{RMaskey}} \tab Askey model (generalized test or triangle model) \cr \command{\link{RMbcw}} \tab bridging model between \command{\link{RMcauchy}} and \command{\link{RMgenfbm}} \cr \command{\link{RMbessel}} \tab Bessel family \cr \command{\link{RMcircular}} \tab circular model \cr \command{\link{RMconstant}} \tab spatially constant model \cr \command{\link{RMcubic}} \tab cubic model (see Chiles and Delfiner) \cr \command{\link{RMdagum}} \tab Dagum model \cr \command{\link{RMdampedcos}} \tab exponentially damped cosine \cr \command{\link{RMqexp}} \tab variant of the exponential model \cr \command{\link{RMfractdiff}} \tab fractionally differenced process \cr \command{\link{RMfractgauss}} \tab fractional Gaussian noise \cr \command{\link{RMgengneiting}} \tab generalized Gneiting model \cr \command{\link{RMgneitingdiff}} \tab Gneiting model for tapering \cr \command{\link{RMhyperbolic}} \tab generalized hyperbolic model \cr \command{\link{RMlgd}} \tab Gneiting's local-global distinguisher\cr \command{\link{RMlsfbm}} \tab locally stationary fractal Brownian motion \cr \command{\link{RMpenta}} \tab penta model (see Chiles and Delfiner) \cr \command{\link{RMpower}} \tab Golubov's model \cr \command{\link{RMwave}} \tab cardinal sine \cr } \bold{Variogram models (stationary increments/intrinsically stationary)} \tabular{ll}{ \command{\link{RMbcw}} \tab bridging model between \command{\link{RMcauchy}} and \command{\link{RMgenfbm}} \cr \command{\link{RMdewijsian}} \tab generalized version of the DeWijsian model \cr \command{\link{RMgenfbm}} \tab generalized fractal Brownian motion \cr \command{\link{RMflatpower}} \tab similar to fractal Brownian motion but always smooth at the origin\cr } \bold{General composed models (operators)} Here, composed models are given that can be of any kind (stationary/non-stationary), depending on the submodel. \tabular{ll}{ % \command{\link{RMCauchy}} \tab Cauchy like transform -- TO BE PROGRAMMED (includes \code{ma1})) \cr \command{\link{RMbernoulli}} \tab Correlation function of a binary field based on a Gaussian field \cr \command{\link{RMexponential}} \tab exponential of a covariance model \cr \command{\link{RMintexp}} \tab integrated exponential of a covariance model (INCLUDES \code{ma2})\cr \command{\link{RMpower}} \tab powered variograms\cr \command{\link{RMqam}} \tab Porcu's quasi-arithmetic-mean model\cr \command{\link{RMS}} \tab details on the optional transformation arguments (\code{var}, \code{scale}, \code{Aniso}, \code{proj}) } \bold{Stationary and isotropic composed models (operators)} \tabular{ll}{ \command{\link{RMcutoff}} \tab Gneiting's modification towards finite range\cr \command{\link{RMintrinsic}} \tab Stein's modification towards finite range\cr \command{\link{RMnatsc}} \tab practical range\cr \command{\link{RMstein}} \tab Stein's modification towards finite range\cr % \command{\link{RMtbm2}} \tab Turning bands operator in two (spatial) % dimensions\cr % nicht an user exportiert \command{\link{RMtbm}}\tab Turning bands operator } \bold{Stationary space-time models} \cr See \link{RMmodelsSpaceTime}. \bold{Non-stationary models} \cr See \link{RMmodelsNonstationary}. \bold{Negative definite models that are not variograms} \tabular{ll}{ \command{\link{RMsum}} \tab a non-stationary variogram model\cr } \bold{Models related to max-stable random fields (tail correlation functions)} \cr See \link{RMmodelsTailCorrelation}. \bold{Other covariance models} \tabular{ll}{ \command{\link{RMcov}} \tab covariance structure given by a variogram\cr \command{\link{RMfixcov}} \tab User defined covariance structure\cr \command{\link{RMuser}} \tab User defined model \cr } \bold{Trend models} \tabular{ll}{ \code{\link[=RMS]{Aniso}} \tab for space transformation (not really trend, but similar)\cr \command{\link{RMcovariate}} \tab spatial covariates\cr \command{\link{RMprod}} \tab to model variability of the variance\cr \command{\link{RMpolynome}} \tab easy modelling of polynomial trends \cr \command{\link{RMtrend}} \tab for explicit trend modelling\cr \command{\link{R.models}} \tab for implicit trend modelling\cr \command{\link{R.c}} \tab for multivariate trend modelling \cr } \bold{Auxiliary models}\cr See \bold{\link{Auxiliary RMmodels}.} } \note{ \itemize{ \item Note that, instead of the named arguments, a single argument \code{k} can be passed. This is possible if all the arguments are scalar. Then \code{k} must have a length equal to the number of arguments. \item If an argument equals \code{NULL} the argument is not set (but must have a valid name). \item \code{Aniso} can be given also by \command{\link{RMangle}} or any other \command{\link{RMmodel}} instead of a matrix \item Note also that a completely different possibility exists to define a model, namely by a list. This format allows for easy flexible models and modifications (and some few more options, as well as some abbreviations to the model names, see \command{PrintModelList()}). Here, the argument \code{var}, \code{scale}, \code{Aniso} and \code{proj} must be passed by the model \command{\link{RMS}}. For instance, \itemize{ \item \code{model <- RMexp(scale=2, var=5)} \cr is equivalent to \cr \code{model <- list("RMS", scale=2, var=5, list("RMexp"))} \cr The latter definition can be also obtained by \code{print(RMexp(scale=2, var=5))} \item \code{model <- RMnsst(phi=RMgauss(var=7), psi=RMfbm(alpha=1.5), scale=2, var=5)} \cr is equivalent to \cr \code{model <- list("RMS", scale=2, var=5,} \cr \code{list("RMnsst", phi=list("RMS", var=7, list("RMgauss")),} \cr \code{psi=list("RMfbm", alpha=1.5)) )}. } All models have secondary names that stem from \pkg{RandomFields} versions 2 and earlier and that can also be used as strings in the list notation. See \code{\link{RFgetModelNames}(internal=FALSE)} for the full list. } } %\section{Methods}{ % \describe{ % \item{[}{\code{signature(x = "RFgridDataFrame")}: selects % slot by name} % \item{[<-}{\code{signature(x = "RFgridDataFrame")}: replaces % slot by name} % \item{as}{\code{signature(x = "RFgridDataFrame")}: % converts into other formats, only implemented for target class % \command{\link[=RFpointsDataFrame-class]{RFpointsDataFrame}} } % \item{cbind}{\code{signature(...)}: if arguments have identical % topology, combine their attribute values} % } %} \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. % \item Gneiting, T. and Schlather, M. (2004) % Statistical modeling with covariance functions. % \emph{In preparation.} \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. % \item Schlather, M. (2002) Models for stationary max-stable % random fields. \emph{Extremes} \bold{5}, 33-44. \item Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/} \sQuote{\href{../doc/multivariate_jss.pdf}{multivariate}}, the corresponding vignette. \item Yaglom, A.M. (1987) \emph{Correlation Theory of Stationary and Related Random Functions I, Basic Results.} New York: Springer. \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3nd edition. } } \seealso{\command{\link{RFformula}}, \link{RM}, \command{\link{RMmodels}}, \command{\link{RMmodelsAuxiliary}}. } \author{Alexander Malinowski; \martin} \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a non-stationary field with a sharp boundary ## of the differentiabilities x <- seq(-0.6, 0.6, len=50) model <- RMwhittle(nu=0.8 + 1.5 * R.is(R.p(new="isotropic"), "<=", 0.5)) z <- RFsimulate(model=model, x, x, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMqexp.Rd0000644000176200001440000000200113437301604015071 0ustar liggesusers\name{RMqexp} \alias{RMqexp} \title{Variant of the exponential model} \description{ The covariance function is \deqn{C(x)= ( 2 e^{-x} - \alpha e^{-2x} ) / ( 2 - \alpha )} } \usage{ RMqexp(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{value in \eqn{[0,1]}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMqexp}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item ? } } \me \seealso{ \command{\link{RMmodel}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqexp(alpha=0.95, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}} RandomFields/man/RMgenfbm.Rd0000644000176200001440000000437313437301604015370 0ustar liggesusers\name{RMgenfbm} \alias{RMgenfbm} \title{Generalized Fractal Brownian Motion Variogram Model} \description{ \command{\link{RMgenfbm}} is an intrinsically stationary isotropic variogram model. The corresponding centered semi-variogram only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{\gamma(r) = (r^{\alpha}+1)^{\beta/\alpha}-1}{\gamma(r)=(r^{\alpha}+1)^{\beta/\alpha}-1} where \eqn{\alpha \in (0,2]}{0 < \alpha \le 2} and \eqn{\beta \in (0,2]}.\cr See also \command{\link{RMfbm}}. } \usage{ RMgenfbm(alpha, beta, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; should be in the interval (0,2].} \item{beta}{a numerical value; should be in the interval (0,2].} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above variogram remains unmodified.} } \details{ Here, the variogram of \command{\link{RMfbm}} is modified by the transformation \eqn{(\gamma+1)^{\delta/-1}} on variograms \eqn{\gamma} for \eqn{\delta \in (0,1]}. This original modification allows for further generalization, cf. \command{\link{RMbcw}}. } \value{ \command{\link{RMgenfbm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. (2002) Nonseparable, stationary covariance functions for space-time data, \emph{JASA} \bold{97}, 590-600. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. % \item Martin's Toledo-Chapter: Construction of covariance functions % and unconditional simulation of random fields, Application to variograms } } \me \seealso{ \command{\link{RMbcw}}, \command{\link{RMfbm}}, \command{\link{RMmodel}}, \command{\link{RMflatpower}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgenfbm(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMS.Rd0000644000176200001440000000502713437301604014331 0ustar liggesusers\name{RMS} \alias{RMS} \title{Scaling operator} \description{ \command{\link{RMS}} is an operator that modifies the variance and the coordinates or distances of a submodel \eqn{\phi} by \deqn{C(h) = v * \phi(A*h/s).} \bold{Most users will never call \command{\link{RMS}} directly, see Details.} However, the following describes the arguments \code{var}, \code{scale}, \code{Aniso}, \code{proj} that are common to nearly all models. See \code{\link{RMSadvanced}} for advanced use of these arguments. } \usage{ RMS(phi, var, scale, Aniso, proj, anisoT) } \arguments{ \item{phi}{submodel} \item{var}{is the optional variance parameter \eqn{v}. } \item{scale}{scaling parameter \eqn{s} which is positive. } \item{Aniso}{matrix or \code{\link{RMmodel}}. The optional anisotropy matrix \eqn{A}, multiplied from the right by a distance vector \eqn{x}, i.e. \eqn{Ax}. } \item{proj}{is the optional projection vector which defines a diagonal matrix of zeros and ones and \code{proj} gives the positions of the ones (integer values between 1 and the dimension of \eqn{x}). It also allows for the values \code{'space'} and \code{'time'} in case of space-time modelling. } \item{anisoT}{the transpose of the anisotropy matrix \eqn{B}, multiplied from the left by a distance vector \eqn{x}, i.e. \eqn{x^\top B}. } } \value{ \command{\link{RMS}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ The call in the usage section is equivalent to \code{phi(..., var, scale, anisoT, Aniso, proj)}, where \code{phi} has to be replaced by a valid \command{\link{RMmodel}}. Most users will never call \command{\link{RMS}} directly. } \note{At most one of the arguments \code{Aniso}, \code{anisoT} and \code{proj} may be given at the same time. } \me \seealso{ \command{\link{RMSadvanced}}, \command{\link{RMmodel}}, \command{\link{RMprod}} for an alternative way to define an arbitrary, location dependent variance. There, the standard deviation is given so that \command{\link{RMprod}} might be used even in the multivariate case. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model1 <- RMS(RMexp(), scale=2) model2 <- RMexp(scale=2) x <- seq(0, 10, 0.02) print(all(RFcov(model1, x) == RFcov(model2, x))) # TRUE \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/papers.S02.Rd0000644000176200001440000000223313437301604015521 0ustar liggesusers\name{S02} \alias{S02} \title{Models for stationary max-stable random fields } \description{ Here, the code of the paper on \sQuote{Models for stationary max-stable random fields} is given. } \me \references{ \itemize{ \item Schlather, M. (2002) Models for stationary max-stable random fields. \emph{Extremes} \bold{5}, 33-44. } } \examples{\dontshow{StartExample()} RFoptions(seed=0, xi=1) ## seed = 0 : *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi = 0.5: Frechet margins with alpha=2 ## Due to change in the handling the seeds here are different from the ## seeds in the paper. x <- seq(0, 10, length=128) \dontshow{if(RFoptions()$internal$examples_red){warning("reduced ");x<-seq(0,10,length=4)}} # Fig. 1-4 \dontrun{\dontshow{plot(RFsimulate(RPsmith(RMgauss(s=1.5)), x, x)) # < 1 sec plot(RFsimulate(RPsmith(RMball(s=RRspheric(2, 3, R=3.3))), x, x)) # 30 sec plot(RFsimulate(RPschlather(RMexp()), x, x)) # 1 sec plot(RFsimulate(RPschlather(RMgauss()), x, x)) # 17 sec }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMsum.Rd0000644000176200001440000000261013437301604014726 0ustar liggesusers\name{RMsum} \alias{RMsum} \title{Plain scalar product} \description{ \command{\link{RMsum}} is given by \deqn{C(x,y) = \phi(x) + \phi(y) }{C(x,y) = \phi(x) + \phi(y).} It is a negative definite function although not a variogram. } \usage{ RMsum(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{any function of class \code{\link[=RMmodel-class]{RMmodel}} } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } %\details{} \value{ \command{\link{RMsum}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ Do not mix up this model with \command{\link{RMplus}}. } %\references{ % Wendland, H. \emph{Scattered Data Approximation} (2005) Cambridge: Cambridge % University Press. %} \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMplus}}, \command{\link{RMprod}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ RFfctn(RMsum(RMexp()), 1:10, grid=FALSE) RFfctn(RMsum(RMexp()), 1:10, 1:10, grid=FALSE) RFfctn(RMsum(RMexp()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) }} \dontshow{FinalizeExample()} }RandomFields/man/RFpseudomadogram.Rd0000644000176200001440000000600113437301604017120 0ustar liggesusers\name{RFpseudomadogram} \alias{RFpseudomadogram} \title{Empirical Pseudomadogram} \description{ Calculates the empirical pseudomadogram. The empirical pseudomadogram of two random fields \eqn{X}{X} and \eqn{Y}{Y} is given by \deqn{\gamma(r):=\frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} |(X(t_{i})-X(t_{j}))||(Y(t_{i})-Y(t_{j}))|}{\gamma(r):=1/N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} |(X(t_{i})-X(t_{j}))||(Y(t_{i})-Y(t_{j}))|} where \eqn{t_{i,j}:=t_{i}-t_{j}}{t_{i,j}:=t_{i}-t_{j}}, and where \eqn{N(r)}{N(r)} denotes the number of pairs of data points with distancevector \eqn{t_{i,j}=r}{t_{i,j}=r}. } \usage{ RFpseudomadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} \item{data}{\argData} \item{bin}{\argBin} \item{phi}{\argPhi} \item{theta}{\argTheta} \item{deltaT}{\argDeltaT} \item{vdim}{\argVdim} } \details{ \command{\link{RFpseudomadogram}} computes the empirical pseudomadogram for given (multivariate) spatial data. The spatial coordinates \code{x}, \code{y}, \code{z} should be vectors. For random fields of spatial dimension \eqn{d > 3} write all vectors as columns of matrix x. In this case do neither use y, nor z and write the columns in \code{gridtriple} notation. If the data is spatially located on a grid a fast algorithm based on the fast Fourier transformed (fft) will be used. As advanced option the calculation method can also be changed for grid data (see \command{\link{RFoptions}}.) It is also possible to use \command{\link{RFpseudomadogram}} to calculate the pseudomadogram (see \command{\link{RFoptions}}). } \value{ \command{\link{RFpseudomadogram}} returns objects of class \command{\link[=RFempVariog-class]{RFempVariog}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \author{Jonas Auel; Sebastian Engelke; Johannes Martini; \martin} \seealso{ \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFcov}}, \command{\link{RFmadogram}}. \command{\link{RFvariogram}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) n <- 2 x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFpseudomadogram(data=z) plot(emp.vario) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMbr2bg.Rd0000644000176200001440000000472213437301604015126 0ustar liggesusers\name{RMbr2bg} \alias{RMbr2bg} \title{Transformation from Brown-Resnick to Bernoulli} \description{ This function can be used to model a max-stable process based on a binary field, with the same extremal correlation function as a Brown-Resnick process \deqn{ C_{bg}(h) = \cos(\pi (2\Phi(\sqrt{\gamma(h) / 2}) -1) ) } Here, \eqn{\Phi} is the standard normal distribution function, and \eqn{\gamma} is a \bold{semi-}variogram with sill \deqn{4(erf^{-1}(1/2))^2 = 2 * { \Phi^{-1}( 3 / 4 ) }^2 = 1.819746 / 2 = 0.9098728} } \usage{ RMbr2bg(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ object of class \code{\link[=RMmodel-class]{RMmodel}} } \details{ \command{\link{RMbr2bg}} \cr binary random field \command{\link{RPbernoulli}} simulated with \code{\link{RMbr2bg}(\link{RMmodel}())} has a uncentered covariance function that equals \enumerate{ \item the tail correlation function of the max-stable process constructed with this binary random field \item the tail correlation function of Brown-Resnick process with variogram \command{\link{RMmodel}}. } Note that the reference paper is based on the notion of the (genuine) variogram, whereas the package \pkg{RandomFields} is based on the notion of semi-variogram. So formulae differ by factor 2. } \references{ \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \seealso{ \link{maxstableAdvanced}, \command{\link{RMbr2eg}}, \command{\link{RMmodel}}, \command{\link{RMm2r}}, \command{\link{RPbernoulli}}, \command{\link{RPbrownresnick}}, \command{\link{RPschlather}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(RMbr2eg(model)), x, x) plot(z) \dontshow{FinalizeExample()}}RandomFields/man/RFsimulateAdvanced.Rd0000644000176200001440000004760713437301604017403 0ustar liggesusers\name{RFsimulateAdvanced} \alias{RFsimulateAdvanced} \title{Simulation of Random Fields -- Advanced} \description{ This function simulates \bold{unconditional} random fields: \itemize{ \item univariate and multivariate, spatial and spatio-temporal Gaussian random fields \item \link[=RPpoisson]{stationary Poisson fields} \item \link[=RPchi2]{Chi2 fields} \item \link[=RPt]{t fields} \item \link[=RPbernoulli]{Binary fields} \item \link[=RPmaxstable]{stationary max-stable random fields}. } It also simulates \bold{conditional} random fields for \itemize{ \item univariate and multivariate, spatial and spatio-temporal Gaussian random fields. } For basic simulation of Gaussian random fields, see \link{RFsimulate}. See \link{RFsimulate.more.examples} and \link{RFsimulate.sophisticated.examples} for further examples. } \arguments{ \item{model}{object of class \code{\link[=RMmodel-class]{RMmodel}}, \command{\link{RFformula}} or \command{\link[stats]{formula}}; specifies the model to be simulated \itemize{ \item if of class \code{\link[=RMmodel-class]{RMmodel}}, \code{model} specifies \itemize{ \item the type of random field by using \code{RP}functions, e.g., \itemize{ \item \command{\link{RPgauss}}: Gaussian random field (default if none of the functions in the list is given) % \item \command{\link{RPbernoulli}}: % indicator field, based on a Gaussian field % \item \command{\link{RPpoisson}}: shot noise model % \item \command{\link{RPbrownresnick}}: Brown-Resnick processes % \item \command{\link{RPopitz}}: Extremal t process \item \command{\link{RPsmith}}: Smith model % \item \command{\link{RPschlather}}: Extremal Gaussian process % (also called Schlather model) See\code{ \link{RP}} for an overview. } \item the covariance or variogram model in case of a Gaussian random field (\command{\link{RPgauss}}) and for fields based on Gaussian fields (e.g. \command{\link{RPbernoulli}}); type \code{\link{RFgetModelNames}(type="variogram")} for a list of available models; see also \command{\link{RMmodel}}. \item the shape function in case of a shot noise process; type \code{\link{RFgetModelNames}(type='shape')} for a list of available models. % \item the main structural element of a max-stable field % (\command{\link{RPbrownresnick}}, \command{\link{RPopitz}}, % \command{\link{RPsmith}} and \command{\link{RPschlather}}) } \item if of class \code{\link{RFformula}} or \command{\link[stats]{formula}}, \code{submodel} specifies a linear mixed model where random effects can be modelled by Gaussian random fields; see \command{\link{RFformula}} for details on model specification. } } \item{x}{matrix of coordinates, or vector of x coordinates, or object of class \code{\link[sp:GridTopology-class]{GridTopology}} or \code{\link[raster]{raster}}; if matrix, \code{ncol(x)} is the dimension of the index space; matrix notation is required in case of more than 3 space dimensions; in this case, if \code{grid=FALSE}, \code{x_ij} is the i-th coordinate in the j-th dimension; otherwise, if \code{grid=TRUE}, the columns of \code{x} are interpreted as gridtriples (see \code{grid}); if of class \code{\link[sp:GridTopology-class]{GridTopology}}, \code{x} is interpreted as grid definition and \code{grid} is automatically set to \code{TRUE}. } \item{y}{optional vector of y coordinates, ignored if \code{x} is a matrix} \item{z}{optional vector of z coordinates, ignored if \code{x} is a matrix} \item{T}{optional vector of time coordinates, \code{T} must always be an equidistant vector or given in a gridtriple format (see argument \code{grid}); for each component of \code{T}, the random field is simulated at all location points. } \item{grid}{logical; determines whether the vectors \code{x}, \code{y}, and \code{z} or the columns of \code{x} should be interpreted as a grid definition (see Details). If \code{grid=TRUE}, either \code{x}, \code{y}, and \code{z} must be equidistant vectors in ascending order or the columns of \code{x} must be given in the gridtriple format: \code{c(from, stepsize, len)}. Note: If \code{grid} is not given, \command{\link{RFsimulate}} tries to guess what is meant. \code{c(from, stepsize, len)} (see Details) } \item{data}{matrix, data.frame or object of class \command{\link[=RFsp-class]{RFsp}}; coordinates and response values of measurements in case that conditional simulation is to be performed; if a matrix or a data.frame, the first columns are interpreted as coordinate vectors, and the last column(s) as (multiple) measurement(s) of the field; if \code{x} is missing, \code{data} may contain \code{NA}s, which are then replaced by conditionally simulated values; if \code{data} is missing, unconditional simulation is performed; for details on matching of variable names see Details; if of class \command{\link[=RFsp-class]{RFsp}} } \item{err.model}{same as \code{model}; gives the model of the measurement errors for the measured \code{data} (which must be given in this case!), see Details. \code{err.model=NULL} (default) corresponds to error-free measurements, the most common alternative is \code{err.model=\link{RMnugget}()}; ignored if \code{data} is missing. } \item{distances}{object of class \code{\link{dist}} representing the upper triangular part of the matrix of Euclidean distances between the points at which the field is to be simulated; only applicable for stationary and isotropic models; if not \code{NULL}, \code{dim} must be given and \code{x}, \code{y}, \code{z} and \code{T} must be missing or \code{NULL}. If \code{distances} are given, the current value of \code{spConform}, see \command{\link{RFoptions}}, is ignored and instead \code{spConform=FALSE} is used. (This fact may change in future.) % To Do } \item{dim}{ integer; space or space-time dimension of the field } \item{n}{number of realizations to generate} \item{...}{further options and control arguments for the simulation that are passed to and processed by \command{\link{RFoptions}} } } \details{ \command{\link{RFsimulate}} simulates different classes of random fields, controlled by the wrapping model. If the wrapping function of the \code{model} argument is a covariance or variogram model, i.e., one of the list obtained by \code{\link{RFgetModelNames}(type="variogram", group.by="type")}, by default, a Gaussian field with the corresponding covariance structure is simulated. By default, the simulation method is chosen automatically through internal algorithms. The simulation method can be set explicitly by enclosing the covariance function with a \link[=Gaussian]{method specification}. If other than Gaussian fields are to be simulated, the \code{model} argument must be enclosed by a function specifying the type of the random field. There are different possibilities of passing the locations at which the field is to be simulated. If \code{grid=FALSE}, all coordinate vectors (except for the time component \eqn{T}) must have the same length and the field is only simulated at the locations given by the rows of \eqn{x} or of \code{cbind(x, y, z)}. If \eqn{T} is not missing, the field is simulated for all combinations \eqn{(x[i, ], T[k])} or \eqn{(x[i], y[i], z[i], T[k])}, \eqn{i=1, ..., }\code{nrow(x)}, \eqn{k=1, ..., }\code{length(T)}, even if \code{model} is not explicitly a space-time model. \cr If \code{grid=TRUE}, the vectors \code{x}, \code{y}, \code{z} and \code{T} or the columns of \code{x} and \code{T} are interpreted as a grid definition, i.e. the field is simulated at all locations \eqn{(x_i, y_j, z_k, T_l)}, as given by \code{expand.grid(x, y, z, T)}. Here, \dQuote{grid} means \dQuote{equidistant in each direction}, i.e. all vectors must be equidistant and in ascending order. In case of more than 3 space dimensions, the coordinates must be given in matrix notation. To enable different grid lengths for each direction in combination with the matrix notation, the \dQuote{gridtriple} notation \code{c(from, stepsize, len)} is used: If \code{x}, \code{y}, \code{z}, \code{T} or the columns of \code{x} are of length 3, they are internally replaced by \code{seq(from=from, to=from+(len-1)*stepsize, by=stepsize)} , i.e. the field is simulated at all locations\cr \code{expand.grid(seq(x$from, length.out=x$len, by=x$stepsize), seq(y$from, length.out=y$len, by=y$stepsize), seq(z$from, length.out=z$len, by=z$stepsize), seq(T$from, length.out=T$len, by=T$stepsize))} If \code{data} is passed, conditional simulation is performed. \itemize{ \item If of class \code{\link[=RFsp-class]{RFsp}}, \code{ncol(data@coords)} must equal the dimension of the index space. If \code{data@data} contains only a single variable, variable names are optional. If \code{data@data} contains more than one variable, variables must be named and \code{model} must be given in the tilde notation \code{resp ~ ... } (see \command{\link{RFformula}}) and \code{"resp"} must be contained in \code{names(data@data)}. \item % Beschreibung hier stimmt nicht so ganz mit Examples unten ueberein If \code{data} is a matrix or a data.frame, either \code{ncol(data)} equals \eqn{(dimension of index space + 1)} and the order of the columns is (x, y, z, T, response) or, if \code{data} contains more than one response variable (i.e. \code{ncol(data) > (dimension of index space + 1)}), \code{colnames(data)} must contain \code{colnames(x)} or those of \code{"x", "y", "z", "T"} that are not missing. The response variable name is matched with \code{model}, which must be given in the tilde notation. If \code{"x", "y", "z", "T"} are missing and \code{data} contains \code{NA}s, \code{colnames(data)} must contain an element which starts with \sQuote{data}; the corresponding column and those behind it are interpreted as the given data and those before the corresponding column are interpreted as the coordinates. \item If \code{x} is missing, \command{\link{RFsimulate}} searches for \code{NA}s in the data and performs a conditional simulation for them. } Specification of \code{err.model}: In geostatistics we have two different interpretations of a nugget effect: small scale variability and measurement error. The result of conditional simulation usually does not include the measurement error. Hence the measurement error \code{err.model} must be given separately. For sake of generality, any model (and not only the nugget effect) is allowed. Consequently, \code{err.model} is ignored when unconditional simulation is performed. } \value{By default, an object of the virtual class \command{\link[=RFsp-class]{RFsp}}; result is of class \command{\link[=RFspatialGridDataFrame]{RFspatialGridDataFrame}} if \eqn{[space-time-dimension > 1]} and the coordinates are on a grid, result is of class \command{\link[=RFgridDataFrame]{RFgridDataFrame}} if \eqn{[space-time-dimension = 1]} and the coordinates are on a grid, result is of class \command{\link[=RFspatialPointsDataFrame]{RFspatialPointsDataFrame}} if \eqn{[space-time-dimension > 1]} and the coordinates are not on a grid, result is of class \command{\link[=RFpointsDataFrame]{RFpointsDataFrame}} if \eqn{[space-time-dimension = 1]} and the coordinates are not on a grid. The output format can be switched to the "old" array format using \code{\link{RFoptions}}, either by globally setting \code{\link{RFoptions}(spConform=FALSE)} or by passing \code{spConform=FALSE} in the call of \command{\link{RFsimulate}}. Then the object returned by \command{\link{RFsimulate}} depends on the arguments \code{n} and \code{grid} in the following way:\cr If \code{vdim > 1} the \code{vdim}-variate vector makes the first dimension. If \code{grid=TRUE} an array of the dimension of the random field makes the next dimensions. Here, the dimensions are ordered in the sequence \code{x}, \code{y}, \code{z}, \code{T} (if given). Else if no time component is given, then the values are passed as a single vector. Else if the time component is given the next 2 dimensions give the space and the time, respectively. If \code{n > 1} the repetitions make the last dimension. Note: Conversion between the \pkg{sp} format and the conventional format can be done using the method \command{RFspDataFrame2conventional} and the function \command{conventional2RFspDataFrame}. \code{InitRFsimulate} returns 0 if no error has occurred and a positive value if failed.\cr } \note{Advanced options are \itemize{ \item \code{spConform} (suppressed return of S4 objects) \item \code{practicalrange} (forces range of covariances to be one) \item \code{exactness} (chooses the simulation method by precision) \item \code{seed} (sets \code{\link[base]{.Random.seed}} locally or globally) } See \command{\link{RFoptions}} for further options. } \references{ % Gneiting, T. and Schlather, M. (2004) % Statistical modeling with covariance functions. % \emph{In preparation.} General \itemize{ \item Lantuejoul, Ch. (2002) \emph{Geostatistical simulation.} \bold{New York:} Springer. \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. } Original work: \itemize{ \item Circulant embedding: Chan, G. and Wood, A.T.A. (1997) An algorithm for simulating stationary Gaussian random fields. \emph{J. R. Stat. Soc., Ser. C} \bold{46}, 171-181. Dietrich, C.R. and Newsam, G.N. (1993) A fast and exact method for multidimensional Gaussian stochastic simulations. \emph{Water Resour. Res.} \bold{29}, 2861-2869. Dietrich, C.R. and Newsam, G.N. (1996) A fast and exact method for multidimensional {G}aussian stochastic simulations: Extensions to realizations conditioned on direct and indirect measurement \emph{Water Resour. Res.} \bold{32}, 1643-1652. Wood, A.T.A. and Chan, G. (1994) Simulation of stationary Gaussian processes in \eqn{[0,1]^d}{[0,1]^d} \emph{J. Comput. Graph. Stat.} \bold{3}, 409-432. The code used in \cite{RandomFields} is based on Dietrich and Newsam (1996). \item Intrinsic embedding and Cutoff embedding: Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599. Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M. and Jiang, Y. (2005) Fast and Exact Simulation of Large Gaussian Lattice Systems in \eqn{R^2}: Exploring the Limits \emph{J. Comput. Graph. Statist.} Submitted. \item Markov Gaussian Random Field: Rue, H. (2001) Fast sampling of Gaussian Markov random fields. \emph{J. R. Statist. Soc., Ser. B}, \bold{63} (2), 325-338. Rue, H., Held, L. (2005) \emph{Gaussian Markov Random Fields: Theory and Applications.} Monographs on Statistics and Applied Probability, no \bold{104}, Chapman \& Hall. \item Turning bands method (TBM), turning layers: Dietrich, C.R. (1995) A simple and efficient space domain implementation of the turning bands method. \emph{Water Resour. Res.} \bold{31}, 147-156. Mantoglou, A. and Wilson, J.L. (1982) The turning bands method for simulation of random fields using line generation by a spectral method. \emph{Water. Resour. Res.} \bold{18}, 1379-1394. Matheron, G. (1973) The intrinsic random functions and their applications. \emph{Adv. Appl. Probab.} \bold{5}, 439-468. Schlather, M. (2004) Turning layers: A space-time extension of turning bands. \emph{Submitted} \item Random coins: Matheron, G. (1967) \emph{Elements pour une Theorie des Milieux Poreux}. Paris: Masson. } } \me \seealso{ \command{\link{RFoptions}}, \command{\link{RMmodel}}, \command{\link{RFgui}}, \command{\link[=Gaussian]{methods for simulating Gaussian random fields}}, \command{\link{RFfit}}, \command{\link{RFvariogram}}, \link{RFsimulate.more.examples}, \link{RFsimulate.sophisticated.examples}, \command{\link{RPgauss}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ ############################################################# ## ## ## Example 1: Specification of simulation method ## ## ## ############################################################# ## usage of a specific method ## -- the complete list is obtained by RFgetMethodNames() model <- RMstable(alpha=1.5) x <- runif(100, max=20) y <- runif(100, max=20) # 100 points in 2 dimensional space simulated <- RFsimulate(model = RPdirect(model), x=x, y=y) # cholesky plot(simulated) ############################################################# ## ## ## Example 2: Turnung band with different number of lines ## ## ## ############################################################# model <- RMstable(alpha=1.5) x <- seq(0, 10, 0.01) z <- RFsimulate(model = RPtbm(model), x=x, y=x) plot(z) ############################################################# ## ## ## Example 3: Shot noise fields (random coins) ## ## ## ############################################################# x <- GridTopology(0, .1, 500) z <- RFsimulate(model=RPpoisson(RMgauss()), x=x, mpp.intensity = 100) plot(z) par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1]) z <- RFsimulate(x=x, model=RPpoisson(RMball()), mpp.intensity = 0.1) plot(z) par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1]) ############################################################# ## ## ## Example 4: a 2d random field based on ## ## covariance functions valid in 1d only ## ## ## ############################################################# x <- seq(0, 2, 0.1) model <- RMfbm(alpha=0.5, Aniso=matrix(nrow=1, c(1, 0))) + RMfbm(alpha=0.9, Aniso=matrix(nrow=1, c(0, 1))) z <- RFsimulate(x, x, model=model) plot(z) ############################################################# ## ## ## Example 5 : Brownian sheet ## ## (using Stein's method) ## ## ## ############################################################# # 2d step <- 0.3 ## nicer, but also time consuming if step = 0.1 x <- seq(0, 5, step) alpha <- 1 # in [0,2) z <- RFsimulate(x=x, y=x, model=RMfbm(alpha=alpha)) plot(z) # 3d z <- RFsimulate(x=x, y=x, z=x, model=RMfbm(alpha=alpha)) ############################################################# ## ## ## Example 5 : Non-Geometric anisotropy ## ## ## ############################################################# x <- seq(0.1, 6, 0.12) Aniso <- R.c(R.p(1)^2, R.p(2)^1.5) z <- RFsimulate(RMexp(Aniso = Aniso) + 10, x, x) plot(z) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMaskey.Rd0000644000176200001440000000523113437301604015240 0ustar liggesusers\name{RMaskey} \alias{RMaskey} \alias{RMtent} \alias{truncated power function} \title{Askey model} \description{ Askey's model \deqn{C(x)= (1-x)^\alpha 1_{[0,1]}(x)} } \usage{ RMaskey(alpha, var, scale, Aniso, proj) RMtent(var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value in the interval [0,1]} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This covariance function is valid for dimension \eqn{d}{d} if \eqn{\alpha \ge (d+1)/2}. For \eqn{\alpha=1} we get the well-known triangle (or tent) model, which is only valid on the real line. } \value{ \command{\link{RMaskey}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Covariance function \itemize{ \item Askey, R. (1973) \emph{Radial characteristic functions.} Technical report, Research Center, University of Wisconsin-Madison. \item Golubov, B. I. (1981) On Abel-Poisson type and Riesz means, \emph{Anal. Math.} 7, 161-184. } Applications as covariance function \itemize{ \item Gneiting, T. (1999) Correlation functions for atmospheric data analysis. \emph{Quart. J. Roy. Meteor. Soc.}, 125:2449-2464. \item Gneiting, T. (2002) Compactly supported correlation functions. \emph{J. Multivar. Anal.}, 83:493-508. \item Wendland, H. (1994) \emph{Ein Beitrag zur Interpolation mit radialen Basisfunktionen.} Diplomarbeit, Goettingen. \item Wendland, H. Piecewise polynomial, positive definite and compactly supported radial functions of minimal degree. Adv. Comput. Math., 4:389-396, 1995. } Tail correlation function (for \eqn{\alpha \ge [d / 2] + 1}) \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMbigneiting}}, \command{\link{RMgengneiting}}, \command{\link{RMgneiting}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMtent() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RFratiotest.Rd0000644000176200001440000001160513437301604016135 0ustar liggesusers\name{RFratiotest} \alias{RFratiotest} \alias{print.RFratiotest} \title{Likelihood ratio test} \description{ The function performs an approximate chi2 test or a Monte Carlo likelihood ratio test based on \command{\link{fitgauss}}. Currently, it only works for Gaussian random fields. } \usage{ RFratiotest(nullmodel, alternative, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, alpha, n = 5 / alpha, seed = 0, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, ...) } \arguments{ \item{nullmodel, alternative}{See Details. The set of parameters to be estimated for \code{nullmodel} should be a subset of the parameters to be estimated for \code{alternative} if \code{alternative} is given. } \item{alpha}{value in [0,1] or missing. Significance level. } \item{n}{integer. The test is based on \code{n-1} simulations.} \item{seed}{integer. If not \code{NULL} and not \code{NA}, the \link[base]{.Random.seed} is set to \code{seed}. Otherwise, \command{\link[base]{set.seed}} is set to the value of \code{RFoptions{}$basic$seed} if the latter is not \code{NA}. } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{data}{\argData} \item{lower}{\argLower} \item{upper}{\argUpper} \item{methods}{\argFitmethods} \item{sub.methods}{\argFitsubmethods See \link{RFfit} for details.} \item{users.guess}{\argUsersguess} \item{distances,dim}{\argDistances} \item{optim.control}{\argOptimcontrol} \item{transform}{\argTransform} \item{...}{\argDots} } \note{ An important \command{\link{RFoptions}} is \code{ratiotest_approx}. } \details{ \code{nullmodel} (and the \code{alternative}) can be \itemize{ \item a covariance model, see \command{\link{RMmodel}} or type \code{\link{RFgetModelNames}(type="variogram")} to get all options. If \command{\link{RFoptions}} \code{ratiotest_approx} is \code{TRUE} the chisq approximation is performed. Otherwise a Monte Carlo ratio test is performed. \item \code{\link[=RFfit-class]{RFfit}} or \code{\link[=RMmodelFit-class]{RMmodelFit}} Here, a chisq approximative test is always performed on the already fitted models. } \command{RFratiotest} tries to detect whether \code{nullmodel} is a submodel of \code{alternative}. If it fails, \itemize{ \item a message is printed that says that an \emph{automatic} detection has not been possible; \item it is not guaranteed anymore that the \code{alternative} model returns a (log) likelihood that is at least as large as that of the \code{nullmodel}, even if \code{nullmodel} is a submodel of \code{alternative}. This is due to numerical optimisation which is never perfect. } Otherwise it is guaranteed that the \code{alternative} model has a (log) likelihood that is at least as large as that of the \code{nullmodel}. } \note{ Note that the likelihood ratio test may take a huge amount of time. } \section{Methods}{ \describe{ \item{print}{prints the summary} \item{summary}{gives a summary} } } \value{ The test returns a message whether the null hypothesis, i.e. the smaller model is accepted. Invisibly, a list that also contains \itemize{ \item \code{p}, the \eqn{p}-value \item \code{n} \item \code{data.ratio} the log ratio for the data \item \code{simu.ratio} the log ratio for the simulations \item \code{data.fit} the models fitted to the data \item \code{msg} the message that is also directly returned } It has S3 class \code{"RFratiotest"}. } \me \note{This function does not depend on the value of \command{\link{RFoptions}}\code{()$PracticalRange}. The function \command{RFratiotest} always uses the standard specification of the covariance model as given in \command{\link{RMmodel}}. } \seealso{ \command{\link{RFfit}}, \command{\link{RMmodel}}, \code{\link[=RandomFields-package]{RandomFields}}, \command{\link{weather}}. } \examples{\dontshow{StartExample()} \dontshow{\dontrun{ RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again data(soil) ## see also ?soil soil <- RFspatialPointsDataFrame( coords = soil[, c("x.coord", "y.coord")], data = soil[, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) model <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=NA)) submodel <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=0)) RFratiotest(submodel, model, data=soil["moisture"], modus_operandi="sloppy") }} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{htest} RandomFields/man/RMrational.Rd0000644000176200001440000000130213437301604015730 0ustar liggesusers\name{RMrational} \alias{RMrational} \title{Rational function} \description{ Defines a simple rational function. \deqn{f(h) = (a_1 + a_2 z(h)) / (1 + z(h))} where \deqn{z(h) = h^\top A A^\top h} } \usage{ RMrational(A, a) } \arguments{ \item{A}{a \eqn{d \times d} matrix} \item{a}{a vector of one or two components; the second component has default value zero.} } \value{ \command{\link{RMrational}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \link{S10}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} # see S10 \dontshow{FinalizeExample()} } RandomFields/man/RMbessel.Rd0000644000176200001440000000556513437301604015413 0ustar liggesusers\name{RMbessel} \alias{RMbessel} \alias{RMjbessel} \title{Bessel Family Covariance Model} \description{ \command{\link{RMbessel}} is a stationary isotropic covariance model belonging to the Bessel family. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = 2^\nu \Gamma(\nu+1) r^{-\nu} J_\nu(r)}{C(r) = 2^\nu \Gamma(\nu+1) r^{-\nu} J_\nu(r)} where \eqn{\nu \ge \frac{d-2}2}{\nu \ge (d-2)/2}, \eqn{\Gamma} denotes the gamma function and \eqn{J_\nu}{J_\nu} is a Bessel function of first kind. } \usage{ RMbessel(nu, var, scale, Aniso, proj) } \arguments{ \item{nu}{a numerical value; should be equal to or greater than \eqn{\frac{d-2}2}{(d-2)/2} to provide a valid covariance function for a random field of dimension \eqn{d}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92, cf. Gelfand et al. (2010), p. 26). An important case is \eqn{\nu=-0.5}{\nu=-0.5} which gives the covariance function \deqn{C(r)=\cos(r)}{C(r)=cos(r)} and which is only valid for \eqn{d=1}{d=1}. This equals \command{\link{RMdampedcos}} for \eqn{\lambda = 0}, there. A second important case is \eqn{\nu=0.5}{\nu=0.5} with covariance function \deqn{C(r)=\sin(r)/r}{C(r)=sin(r)/r} which is valid for \eqn{d \le 3}{d \le 3}. This coincides with \command{\link{RMwave}}. Note that all valid continuous stationary isotropic covariance functions for \eqn{d}{d}-dimensional random fields can be written as scale mixtures of a Bessel type covariance function with \eqn{\nu=\frac{d-2}2}{\nu=(d-2)/2} (cf. Gelfand et al., 2010, pp. 21--22). } \value{ \command{\link{RMbessel}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. \item \url{http://homepage.tudelft.nl/11r49/documents/wi4006/bessel.pdf} } } \me \seealso{ \command{\link{RMdampedcos}}, \command{\link{RMwave}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbessel(nu=1, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMbigneiting.Rd0000644000176200001440000001432513437301604016247 0ustar liggesusers\name{RMbigneiting} \alias{RMbigneiting} \alias{RMbiwendland} \title{Gneiting-Wendland Covariance Models} \description{ \command{\link{RMbigneiting}} is a bivariate stationary isotropic covariance model family whose elements are specified by seven parameters. Let \deqn{\delta_{ij} = \mu + \gamma_{ij} + 1.} Then, \deqn{ C_{n}(h) = c_{ij} (C_{n, \delta} (h / s_{ij}))_{i,j=1,2} } and \eqn{ C_{n, \delta} } is the generalized Gneiting model with parameters \eqn{n} and \eqn{\delta}, see \code{\link{RMgengneiting}}, i.e., \deqn{C_{\kappa=0, \delta}(r) = (1-r)^\beta 1_{[0,1]}(r), \qquad \beta=\delta + 2\kappa + 1/2;}{ C_{\kappa=0, \delta}(r) = (1 - r)^\beta 1_{[0,1]}(r), \beta=\delta + 2\kappa + 1/2;} \deqn{C_{\kappa=1, \delta}(r) = \left(1+\beta r \right)(1-r)^{\beta} 1_{[0,1]}(r), \qquad \beta = \delta + 2\kappa + 1/2;}{ C_{\kappa=1, \delta}(r) = (1+ \beta r)(1-r)^\beta 1_{[0,1]}(r), \beta = \delta + 2\kappa + 1/2;} \deqn{C_{\kappa=2, \delta}(r)=\left( 1 + \beta r + \frac{\beta^{2} - 1}{3}r^{2} \right)(1-r)^{\beta} 1_{[0,1]}(r), \qquad \beta=\delta + 2\kappa + 1/2;}{ C(_{\kappa=2, \delta}(r) = (1 + \beta r + (\beta^2-1) r^(2)/3)(1-r)^\beta 1_{[0,1]}(r), \beta = \delta + 2\kappa + 1/2;} \deqn{ C_{\kappa=3, \delta}(r)=\left( 1 + \beta r + \frac{(2\beta^{2}-3)}{5} r^{2}+ \frac{(\beta^2 - 4)\beta}{15} r^{3} \right)(1-r)^\beta 1_{[0,1]}(r), \qquad \beta=\delta+2\kappa+1/2.}{ C_{\kappa=3, \delta}(r) = (1 + \beta r + (2 \beta^2-3 )r^(2)/5+(\beta^2 - 4) \beta r^(3)/15)(1-r)^\beta 1_{[0,1]}(r), \beta=\delta + 2\kappa + 1/2.} } \usage{ RMbigneiting(kappa, mu, s, sred12, gamma, cdiag, rhored, c, var, scale, Aniso, proj) } \arguments{ \item{kappa}{argument that chooses between the four different covariance models and may take values \eqn{0,\ldots,3}{0,...,3}. The model is \eqn{k} times differentiable.} \item{mu}{\code{mu} has to be greater than or equal to \eqn{\frac{d}{2}}{d/2} where \eqn{d}{d} is the (arbitrary) dimension of the random field.} \item{s}{vector of two elements giving the scale of the models on the diagonal, i.e. the vector \eqn{(s_{11}, s_{22})}. } \item{sred12}{value in \eqn{[-1,1]}. The scale on the offdiagonals is given by \eqn{s_{12} = s_{21} =} \code{sred12 *} \eqn{\min\{s_{11},s_{22}\}}{min{s_{11}, s_{22}}}. } \item{gamma}{a vector of length 3 of numerical values; each entry is positive. The vector \code{gamma} equals \eqn{(\gamma_{11},\gamma_{21},\gamma_{22})}. Note that \eqn{\gamma_{12} =\gamma_{21}}. } \item{cdiag}{a vector of length 2 of numerical values; each entry positive; the vector \eqn{(c_{11},c_{22})}.} \item{c}{a vector of length 3 of numerical values; the vector \eqn{(c_{11}, c_{21}, c_{22})}. Note that \eqn{c_{12}= c_{21}}. Either \code{rhored} and \code{cdiag} or \code{c} must be given. } \item{rhored}{value in \eqn{[-1,1]}. See also the Details for the corresponding value of \eqn{c_{12}=c_{21}}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ A sufficient condition for the constant \eqn{c_{ij}} is \deqn{c_{12} = \rho_{\rm red} \cdot m \cdot \left(c_{11} c_{22} \prod_{i,j=1,2} \left(\frac{\Gamma(\gamma_{ij} + \mu + 2\kappa + 5/2)}{b_{ij}^{\nu_{ij} + 2\kappa + 1} \Gamma(1 + \gamma_{ij}) \Gamma(\mu + 2\kappa + 3/2)} \right)^{(-1)^{i+j}} \right)^{1/2} }{ c_{ij} = \rho_r m (c_{11} c_{22})^{1/2} } where \eqn{\rho_{\rm red} \in [-1,1]}{\rho_r in [-1,1]}. The constant \eqn{m} in the formula above is obtained as follows: \deqn{m = \min\{1, m_{-1}, m_{+1}\}}{m = min\{1, m_{-1}, m_{+1}\}} Let \deqn{a = 2 \gamma_{12} - \gamma_{11} -\gamma_{22}} \deqn{b = -2 \gamma_{12} (s_{11} + s_{22}) + \gamma_{11} (s_{12} + s_{22}) + \gamma_{22} (s_{12} + s_{11})} \deqn{e = 2 \gamma_{12} s_{11}s_{22} - \gamma_{11}s_{12}s_{22} - \gamma_{22}s_{12}s_{11}} \deqn{d = b^2 - 4ae} \deqn{t_j =\frac{- b + j \sqrt d}{2 a} }{t_j =(-b + j \sqrt d) / (2 a) } If \eqn{d \ge0} and \eqn{t_j \not\in (0, s_{12})}{t_j in (0, s_{12})^c} then \eqn{m_j=\infty} else \deqn{ m_j = \frac{(1 - t_j/s_{11})^{\gamma_{11}}(1 - t_j/s_{22})^{\gamma_{22}}}{(1 - t_j/s_{12})^{2 \gamma_{11}} }{ m_j = (1 - t_j/s_{11})^{\gamma_{11}} (1 - t_j/s_{22})^{\gamma_{22}} / (1 - t_j/s_{12})^{2 \gamma_{11}} } } In the function \command{\link{RMbigneiting}}, either \code{c} is passed, then the above condition is checked, or \code{rhored} is passed; then \eqn{c_{12}} is calculated by the above formula. } \value{ \command{\link{RMbigneiting}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Bevilacqua, M., Daley, D.J., Porcu, E., Schlather, M. (2012) Classes of compactly supported correlation functions for multivariate random fields. Technical report. \code{RMbigeneiting} is based on this original work. D.J. Daley, E. Porcu and M. Bevilacqua have published end of 2014 an article intentionally without clarifying the genuine authorship of \code{RMbigneiting}, in particular, neither referring to this original work nor to \pkg{RandomFields}, which has included \code{RMbigneiting} since version 3.0.5 (05 Dec 2013). \item Gneiting, T. (1999) Correlation functions for atmospherical data analysis. \emph{Q. J. Roy. Meteor. Soc} Part A \bold{125}, 2449-2464. \item Wendland, H. (2005) \emph{Scattered Data Approximation.} {Cambridge Monogr. Appl. Comput. Math.} } } \me \seealso{ \command{\link{RMaskey}}, \command{\link{RMbiwm}}, \command{\link{RMgengneiting}}, \command{\link{RMgneiting}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again %# gamma is mainly a scale effect model <- RMbigneiting(kappa=2, mu=0.5, gamma=c(0, 3, 6), rhored=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMmodelsTailcorrelation.Rd0000644000176200001440000000733213437301604020467 0ustar liggesusers\name{Tail Correlation Functions} \alias{tcf} \alias{tail correlation functions} \alias{Tail correlation functions} \alias{RMmodelsTailCorrelation} \title{Covariance models valid for max-stable random fields} \description{ This page summarizes the models that can be used for tail correlation functions. } \details{ The following models are available: \bold{Completely monotone functions allowing for arbitrary scale} \tabular{ll}{ \command{\link{RMbcw}} \tab Model bridging stationary and intrinsically stationary processes for \code{alpha <= 1} and \code{beta < 0}\cr \command{\link{RMdagum}} \tab Dagum model with \eqn{\beta < \gamma} and \eqn{\gamma \le 1}\cr \command{\link{RMexp}} \tab exponential model \cr \command{\link{RMgencauchy}} \tab generalized Cauchy family with \eqn{\alpha \le 1} (and arbitrary \eqn{\beta> 0})\cr \command{\link{RMmatern}} \tab Whittle-Matern model with \eqn{\nu \le 1/2}\cr %multiquadric todo %sine power todo \command{\link{RMstable}} \tab symmetric stable family or powered exponential model with \eqn{\alpha \le 1}\cr \command{\link{RMwhittle}} \tab Whittle-Matern model, alternative parametrization with \eqn{\nu \le 1/2}\cr } \bold{Other isotropic models with arbitrary scale} \tabular{ll}{ \command{\link{RMnugget}} \tab nugget effect model \cr } \bold{Compactly supported covariance functions} \tabular{ll}{ \command{\link{RMaskey}} \tab Askey's model\cr \command{\link{RMcircular}} \tab circular model\cr \command{\link{RMconstant}}\tab identically constant \cr \command{\link{RMcubic}} \tab cubic model\cr \command{\link{RMgengneiting}} \tab Wendland-Gneiting model; differentiable models with compact support \cr \command{\link{RMgneiting}} \tab differentiable model with compact support \cr \command{\link{RMspheric}} \tab spherical model \cr } \bold{Anisotropic models} \tabular{ll}{ None up to now. } \bold{Basic Operators} \tabular{ll}{ \command{\link{RMmult}}, \code{*} \tab product of covariance models \cr \command{\link{RMplus}}, \code{+} \tab sum of covariance models or variograms\cr } \bold{Operators related to process constructions} \tabular{ll}{ \command{\link{RMbernoulli}} \tab correlation of binary fields\cr \command{\link{RMbrownresnick}}\tab tcf of a \link{Brown-Resnick} process\cr \command{\link{RMschlather}}\tab tcf of an extremal Gaussian process / \link[=RMschlather]{Schlather} process \cr \command{\link{RMm2r}}\tab M2 process with monotone shape function\cr \command{\link{RMm3b}}\tab M3 process with balls of random radius\cr \command{\link{RMmps}}\tab M3 process with hyperplane polygons\cr % \command{\link{}}\tab \cr } \bold{See \link{RMmodels} for cartesian models.} } \references{ \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2015) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{18}, 241-271 } } \me \seealso{ \link{coordinate systems}, \link{RM}, \command{\link{RMmodels}}, \command{\link{RMtrafo}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="tail") ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model) \dontshow{FinalizeExample()}}RandomFields/man/RMdelay.Rd0000644000176200001440000000454713437301604015233 0ustar liggesusers\name{RMdelay} \alias{RMdelay} \title{Bivariate Delay Effect} \description{ \command{\link{RMdelay}} is a \eqn{(m+1)}-variate stationary covariance model. which depends on a univariate stationary covariance model \eqn{C_0}. The corresponding covariance function only depends on the difference \eqn{h \in {\bf R}^d}{h} between two points in \eqn{d}-dimensional space and is given by \deqn{C(h)=(C_0(h - s_i +s_j))_{i,j=0,\ldots,m}} where \eqn{s \in {\bf R}^{d\times m}}{h \in R^{d x m}} and \eqn{s_0=0} } \usage{ RMdelay(phi,s,var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary covariance model, that means an \command{\link{RMmodel}} whose \command{vdim} equals 1.} \item{s}{a \eqn{d\times m}{d x m}-dimensional shift matrix, where \eqn{d} is the dimension of the space, giving the components \eqn{s=(s_1,\ldots, s_m)}{s=(s_1,..., s_m)} where the \eqn{s_i} are vectors.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{%See Wackernagel, H. (2003), p.?) Here, a multivariate random field is obtained from a single univariate random field by shifting it by a fixed value. } \value{ \command{\link{RMdelay}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/} \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3nd edition. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10,10,0.2) model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(4,4)) plot(model, dim=2, xlim=c(-6, 6), ylim=c(-6,6)) simu <- RFsimulate(model, x, y) plot(simu, zlim="joint") \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMstein.Rd0000644000176200001440000000354513437301604015254 0ustar liggesusers\name{RMstein} \alias{RMstein} \title{Stein's non-separable space-time model} \description{ \command{\link{RMstein}} is a univariate stationary covariance model whose corresponding covariance function only depends on the difference \eqn{h}{h} between two points and is given by \deqn{C(h, t) = W_{\nu}(y) - ( < h, z > t)/((\nu - 1)(2\nu + d)) * W_{\nu-1}(y)}{ C(h, t) = W_\nu(y) - < h, z > t W_{\nu-1}(y) / [ (\nu-1) (2\nu + d + 1) ]} Here, \eqn{W_\nu} is the covariance of the \command{\link{RMwhittle}} model with smoothness parameter \eqn{\nu}; \eqn{y=\|(h,t)\|}{y = ||(h,t)||} is the norm of the vector \eqn{(h,t)}{(h,t)}, \eqn{d}{d} is the dimension of the space on which the random field is considered. } \usage{ RMstein(nu, z, var, scale, Aniso, proj) } \arguments{ \item{nu}{numerical value; greater than 1; smoothness parameter of the RMwhittle model} \item{z}{a vector; the norm of \eqn{z}{z} must be less or equal to 1.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{See Stein (2005). } \value{ \command{\link{RMstein}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Stein, M.L. (2005) Space-time covariance functions. \emph{J. Amer. Statist. Assoc.} \bold{100}, 310-321. Equation (8). } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstein(nu=1.5, z=0.9) x <- seq(0, 10, 0.05) plot(RFsimulate(model, x=x, y=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMgneitingdiff.Rd0000644000176200001440000000401313437301604016556 0ustar liggesusers\name{RMgneitingdiff} \alias{RMgneitingdiff} \title{Gneiting Covariance Model Used as Tapering Function} \description{ \command{\link{RMgneitingdiff}} is a stationary isotropic covariance model which is only valid up to dimension 3. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(h) = C_0(h / t) W_\nu(h / s)} where \eqn{C_0} is Gneiting's model \command{\link{RMgneiting}} and \eqn{W_\nu} is the Whittle model \command{\link{RMwhittle}}. } \usage{ RMgneitingdiff(nu, taper.scale, scale, var, Aniso, proj) } \arguments{ \item{nu}{see \command{\link{RMwhittle}} } \item{taper.scale}{is the parameter \eqn{t} in the above formula.} \item{scale}{is the parameter \eqn{s} in the above formula.} \item{var,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model allows to a certain degree the smooth modelling of the differentiability of a covariance function with compact support. } \value{ \command{\link{RMgneitingdiff}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. (1999) Correlation functions for atmospherical data analysis. \emph{Q. J. Roy. Meteor. Soc} Part A \bold{125}, 2449-2464. } } \me \seealso{ \command{\link{RMbigneiting}}, \command{\link{RMgneiting}}, \command{\link{RMgengneiting}}, \command{\link{RMgauss}}, \command{\link{RMmodel}}, \command{\link{RMwhittle}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgneitingdiff(nu=2, taper.scale=1, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMbubble.Rd0000644000176200001440000001413213437301604015357 0ustar liggesusers\name{RMbubble} \alias{RMbubble} \title{Bubble model for arbitrary areas of scales} \description{ A model that allows for arbitray areas of scale applied to an isotropic model, i.e. \deqn{ C(x,y) = \phi(\|x -y \| / s) } as long as \eqn{s_x = s_y = s}. Here, \eqn{s_x} is the scaling at location \eqn{x}, The cross-correlations between areas of different scales are given through a modified distance \eqn{d}. Let \eqn{z_{s}} be a finite subset of \eqn{R^d} depending on the scale \eqn{s}. Let \eqn{w_u} be a weight for an auxiliary point \eqn{u\in z_{s}} with \eqn{\sum_{u \in z_s} w_u = 1}. Let \eqn{\tau_x = s_x^{-2}}. Then \deqn{d^2(x, y) = \min\{\tau(x), \tau(y)\} \|x - y\|^2 + \sum_{\xi \in_{span(\tau(x), \tau(y))}} \sum_{u \in z_{\xi^{-0.5}}} w_u \|x - u\|^2 \Delta \xi } Here, \eqn{span(\tau(x), \tau(y))} is the finite set of values \eqn{s^{-2}} that are realized on the locations of interest and \eqn{\Delta \xi} is the difference of two realized and ordered values of the scaling \eqn{s}. } \usage{ RMbubble(phi, scaling, z, weight, minscale, barycentre, var, scale, Aniso, proj)} \arguments{ \item{phi}{isotropic submodel} \item{scaling}{model that gives the non-stationary scaling \eqn{s_x}} \item{z}{ matrix of the union of all \eqn{z_s}. The number of rows equals the dimension of the field. If not given, the locations with non-vanishing gradient are taken. } \item{weight}{vector of weights \eqn{w} whose length equals the number of columns of \code{z}. The points given by \code{z} might be weighted. } \item{minscale}{vector for partioning \eqn{z} into classes \eqn{z_s}. Its length equals the number of columns of \code{z}. The vector values must be descending. See details. If not given then \eqn{z_s=}\code{z} for all \eqn{s}. Else see details. } \item{barycentre}{logical. If \code{FALSE} and \code{z} is not given, the reference locations are those with non-vashing gradient. If \code{TRUE} then, for each realized value of the scale, the barycentre of the corresponding reference locations is used instead of the reference locations themselves. This leads to higher correlations, but also to highly non-stationary cross-correlation between the areas of different scale. The argument has no effect when \code{z} is given. Default: \code{FALSE}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMbubble}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ \code{minscale} gives the minimal scale \eqn{s} value above which the corresponding points \code{z} define the set \eqn{z_s}. The validity of the set \eqn{z_s} ends with the next lower value given. Let \code{minscale = (10, 10, 10, 7, 7, 7, 0.5)}. Then for some \eqn{d}-dimensional vectors \eqn{z_1,\ldots, z_7} we have \deqn{z_s = \{ z_1, z_2, z_3 \}, s \ge 10} \deqn{z_s = \{ z_4, z_5, z_5 \}, 7 \ge s < 10} \deqn{z_s = \{ z_7 \}, s \ge 0.5} Note that, in this case, all realized scaling values must be \eqn{\ge 0.5}. Note further, that the weights for the subset must sum up to one, i.e. \deqn{w_1+w_2 +w_3=w_4 + w_5 + w_6 = w_7 = 1.} } \note{This model is defined only for grids.} \references{ \itemize{ \item Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation. } } \me \seealso{ \command{\link{RMSadvanced}}, \command{\link{RMblend}}, \command{\link{RMscale}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.02 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) ## two models: ## the frist uses the standard approach for determining the ## reference point z, which is based on gradients ## the second takes the centre of the ball model1 <- RMbubble(RMexp(), scaling=scale) model2 <- RMbubble(RMexp(), scaling=scale, z=c(0.5, 0.5)) model3 <- RMbubble(RMexp(), scaling=scale, barycentre=TRUE) # approx. of model2 ## model2 has slightly higher correlations than model1: C1 <- RFcovmatrix(model1, x, x) C2 <- RFcovmatrix(model2, x, x) C3 <- RFcovmatrix(model3, x, x) print(range(C2 - C1)) dev.new(); hist(C2 - C1) print(range(C3 - C2)) # only small differences to C2 print(mean(C3 - C2)) dev.new(); hist(C3 - C2) plot(z1 <- RFsimulate(model1, x, x)) plot(z2 <- RFsimulate(model2, x, x)) plot(z3 <- RFsimulate(model3, x, x)) # only tiny differences to z2 ## in the following we compare the standard bubble model with ## the models RMblend, RMscale and RMS (so, model2 above ## performs even better) biwm <- RMbiwm(nudiag=c(0.5, 0.5), nured=1, rhored=1, cdiag=c(1, 1), s=c(0.5, 2.5, 0.5)) blend <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(d), raw=TRUE)) plot(zblend <- RFsimulate(blend, x, x)) ## takes a while ... Cblend <- RFcovmatrix(blend, x, x) Mscale <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(zscale <- RFsimulate(Mscale, x, x)) Cscale <- RFcovmatrix(Mscale, x, x) Mscale2 <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 20000) plot(zscale2 <- RFsimulate(Mscale2, x, x)) Cscale2 <- RFcovmatrix(Mscale2, x, x) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x) print(range(C1 - CS)) print(range(C1 - Cscale)) print(range(C1 - Cscale2)) print(range(C1 - Cblend)) dev.new(); hist(C1-CS) ## C1 is better dev.new(); hist(C1-Cscale) ## C1 is better dev.new(); hist(C1-Cscale2) ## both are equally good. Maybe C1 slightly better dev.new(); hist(C1-Cblend) ## C1 is better \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMfix.Rd0000644000176200001440000000541213437301604014713 0ustar liggesusers\name{RMfixcov} \alias{RMfixcov} \title{Fixed Covariance Matrix} \description{ \command{\link{RMfixcov}} is a user-defined covariance according to the given covariance matrix. It extends to the space through a Voronoi tessellation. } \usage{ RMfixcov(M, x, y=NULL, z=NULL, T=NULL, grid, var, proj, raw, norm) } \arguments{ \item{M}{a numerical matrix defining the user-defined covariance for a random field; the matrix should be positive definite, symmetric and its dimension should be equal to the length of observation or simulation vector.} \item{x,y,z,T,grid}{optional. The usual arguments as in \command{\link{RFsimulate}} to define the locations where the covariates are given. } \item{var,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} \item{raw}{\argRaw} \item{norm}{\argNorm} % \item{vdim}{an integer value; defining the response dimension.} } \note{ Starting with version 3.0.64, the former argument \code{element} is replaced by the \code{general} option \code{set} in \command{\link{RFoptions}}. } \details{ The covariances passed are implemented for the given locations. Within any Voronoi cell (around a given location) the correlation is assumed to be one. In particular, it is used in \command{\link{RFfit}} to define neighbour or network structure in the data. } \value{ \command{\link{RMfixcov}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Ober, U., Ayroles, J.F., Stone, E.A., Richards, S., Zhu, D., Gibbs, R.A., Stricker, C., Gianola, D., Schlather, M., Mackay, T.F.C., Simianer, H. (2012): \emph{Using Whole Genome Sequence Data to Predict Quantitative Trait Phenotypes in Drosophila melanogaster}. PLoS Genet 8(5): e1002685. } } \me \seealso{ \command{\link{RMcovariate}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RMuser}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample(reduce=FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example 1 showing that the covariance structure is correctly implemented n <- 10 C <- matrix(runif(n^2), nc=n) (C <- C \%*\% t(C)) RFcovmatrix(RMfixcov(C), 1:n) ## Example 2 showing that the covariance structure is interpolated RFcovmatrix(RMfixcov(C, 1:n), c(2, 2.1, 2.5, 3)) ## Example 3 showing the use in a separable space-time model model <- RMfixcov(C, 1:n, proj="space") * RMexp(s=40, proj="time") (z <- RFsimulate(model, x = seq(0,12, 0.5), T=1:100)) plot(z) \dontshow{FinalizeExample()}}RandomFields/man/RFfit-class.Rd0000644000176200001440000002226013437301604016003 0ustar liggesusers\name{RFfit-class} \docType{class} \alias{RFfit-class} \alias{RF_fit-class} \alias{show,RFfit-method} \alias{persp,RFfit-method} \alias{print,RFfit-method} \alias{anova,RFfit-method} \alias{AIC,RFfit-method} \alias{BIC,RFfit-method} \alias{summary,RFfit-methodt} \alias{[,RFfit-method} \alias{[,RFfit,ANY,ANY-method} \alias{[,RFfit,ANY,ANY,ANY-method} \alias{coerce,RFfit,RFempVariog-method} \alias{print.RFfit} \alias{plot,RFfit,missing-method} \alias{contour.RFfit} \alias{contour.RFempVariog} \alias{AICc.RFfit} \alias{logLik.RFfit} \alias{print.RF_fit} \alias{anova.RF_fit} \alias{AIC.RF_fit} \alias{BIC.RF_fit} \alias{AICc.RF_fit} \alias{summary.RF_fit} \alias{logLik.RF_fit} \alias{.RFfit} \alias{.RF_fit} \alias{residuals,RFfit-method} \alias{summary,RFfit-method} \alias{RFhessian} %\alias{plot,RFfit-method} \title{Class \code{RFfit}} \description{ Class for RandomFields' representation of model estimation results } %anova.RF_fit(object, ...) %AIC.RF_fit(object, ..., k=2, method="ml", full=TRUE) %BIC.RF_fit(object, ..., method="ml", full=TRUE) %summary.RF_fit(object, ..., method="ml", full=FALSE) %print.RF_fit(x, ..., method="ml", full=FALSE) %logLik.RF_fit(object, REML = FALSE, ..., method="ml") \usage{ \S4method{residuals}{RFfit}(object, ..., method="ml", full=FALSE) \S4method{summary}{RFfit}(object, ..., method="ml") \S4method{plot}{RFfit,missing}(x, y, ...) \S3method{contour}{RFfit}(x, ...) \S3method{contour}{RFempVariog}(x, ...) RFhessian(model) } \arguments{ \item{object}{see the generic function; } \item{...}{ \itemize{ \item \command{plot}: arguments to be passed to methods; mainly graphical arguments, or further models in case of class \code{CLASS_CLIST}, see Details. \item \command{summary}: see the generic function \item \command{contour} : see \command{\link{RFplotEmpVariogram}} } } \item{method}{character; only for \code{class(x)=="RFfit"}; a vector of slot names for which the fitted covariance or variogram model is to be plotted; should be a subset of \code{slotNames(x)} for which the corresponding slots are of class \code{CLASS_FIT}; by default, the maximum likelihood fit (\code{"ml"}) will be plotted} \item{full}{logical. if \code{TRUE} submodels are reported as well (if available). } \item{x}{object of class \code{\link[=RFsp-class]{RFsp}} or \command{\link[=RFempVariog-class]{RFempVariog}} or \command{\link[=RFfit-class]{RFfit}} or \command{\link[=RMmodel-class]{RMmodel}}; in the latter case, \code{x} can be any sophisticated model but it must be either stationary or a variogram model} \item{y}{unused} \item{model}{ \code{class(x)=="RF_fit"} or \code{class(x)=="RFfit"}, obtained from \command{\link{RFfit}} } } \details{ for the definition of \command{plot} see \command{\link{RFplotEmpVariogram}}. } \section{Creating Objects}{ Objects are created by the function \command{\link{RFfit}} } \section{Slots}{ \describe{ \item{\code{autostart}:}{RMmodelFit; contains the estimation results for the method 'autostart' including a likelihood value, a constant trend and the residuals} \item{\code{boxcox}:}{logical; whether the parameter of a Box Cox tranformation has been estimated } \item{\code{coordunits}:}{string giving the units of the coordinates, see also option \code{coordunits} of \command{\link{RFoptions}}. } \item{\code{deleted}:}{integer vector. Positions of the parameters that have been deleted to get the set of variables, used in the optimization. } \item{\code{ev}:}{list; list of objects of class \code{\link[=RFempVariog-class]{RFempVariog}}, contains the empirical variogram estimates of the data} \item{\code{fixed}:}{ list of two vectors. The fist gives the position where the parameters are set to zero. The second gives the position where the parameters are set to one. } \item{\code{internal1}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{internal2}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{internal3}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{lowerbounds}:}{RMmodel; covariance model in which each parameter value gives the lower bound for the respective parameter} \item{\code{ml}:}{RMmodelFit; analog to slot 'autostart' } \item{\code{modelinfo}:}{ table with information on the parameters: name, boundaries, type of parameter } \item{\code{n.covariates}:}{ number of covariates } \item{\code{n.param}:}{ number of parameters (given by the user) } \item{\code{n.variab}:}{ number of variables (used internally); \code{n.variab} is always less than or equal to \code{n.param} } \item{\code{number.of.data}:}{ the number of data values passed to \command{\link{RFfit}} that are not \code{NA} or \code{NaN} } \item{\code{number.of.parameters}:}{ total number of parameters of the model that had to be estimated including variances, scales, co-variables, etc. } \item{\code{p.proj}:}{vector of integers. The original position of those parameters that are used in the submodel } \item{\code{plain}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{report}:}{ If not empty, it indicates that this model should be reported and gives a standard name of the model. Various functions, e.g. \command{print.RMmodelFit}, use this information if their argument \code{full} equals \code{TRUE}. } \item{\code{self}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{sd.inv}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{sqrt.nr}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{submodels}:}{ list. Sequence (in some cases even nested sequence) of models that is used to determine an initial value in \command{} } \item{\code{table}:}{matrix; summary of estimation results of different methods} \item{\code{transform}:}{function; } \item{\code{true.tsdim}:}{ time space dimension of the (original!) data, even for submodels that consider parts of separable models. } \item{\code{true.vdim}:}{ multivariability of the (original!) data, even for submodels that consider independent models for the multivariate components. } \item{\code{upperbounds}:}{RMmodel; see slot 'lowerbounds'} \item{\code{users.guess}:}{RMmodelFit; analog to slot 'autostart'} \item{\code{ml}:}{RMmodelFit; analog to slot 'autostart'; with maximum likelihood method} \item{\code{v.proj}:}{vector of integers. The components selected in one of the submodels } \item{\code{varunits}:}{string giving the units of the variables, see also option \code{varunits} of \command{\link{RFoptions}}. } \item{\code{x.proj}:}{ logical or integer. If logical, it means that no separable model is considered there. If integer, then it gives the considered directions of a separable model. } \item{\code{Z}:}{ standardized list of information on the data } } } %\section{Extends}{ %} \section{Methods}{ \describe{ \item{plot}{\code{signature(x = "RFfit")}: gives a plot of the empirical variogram together with the fitted model, for more details see \command{\link{plot-method}}. } \item{show}{\code{signature(x = "RFfit")}: returns the structure of \code{x} } \item{persp}{\code{signature(obj = "RFfit")}: generates \command{\link[graphics]{persp}} plots } \item{print}{\code{signature(x = "RFfit")}: identical with \command{show}-method, additional argument is \code{max.level} } \item{[}{\code{signature(x = "RFfit")}: enables accessing the slots via the \code{"["}-operator, e.g. \code{x["ml"]} } \item{as}{\code{signature(x = "RFfit")}: converts into other formats, only implemented for target class \code{\link[=RFempVariog-class]{RFempVariog}} } \item{anova}{performs a likelihood ratio test base on a chisq approximation } \item{summary}{provides a summary} \item{logLik}{provides an object of class \code{"logLik"} } \item{AIC,BIC}{provides the AIC and BIC information, respectively} \item{\code{signature(x = "RFfit", y = "missing")}}{Combines the plot of the empirical variogram with the estimated covariance or variogram model (theoretical) curves; further models can be added via the argument \code{model}.} } } \section{Further 'methods'}{ \code{AICc.RFfit(object, ..., method="ml", full=FALSE)} \code{AICc.RF_fit(object, ..., method="ml", full=TRUE)} } %\section{Details}{ %} \author{Alexander Malinowski; \martin} \seealso{ \code{\link{RFfit}}, \code{\link{RFvariogram}}, \code{\link{RMmodel-class}}, \code{\link{RMmodelFit-class}}, \code{\link{plot-method}}. } \references{ AICc: \itemize{ \item Hurvich, C.M. and Tsai, C.-L. (1989) Regression and Time Series Model Selection in Small Samples \emph{Biometrika}, \bold{76}, 297-307. } } \examples{\dontshow{StartExample()} # see RFfit \dontshow{FinalizeExample()} } \keyword{classes} \keyword{print} \keyword{hplot} RandomFields/man/RPmaxstable.Rd0000644000176200001440000000525513437301604016115 0ustar liggesusers\name{Max-stable random fields} \alias{maxstable} \alias{Maxstable} \alias{RPmaxstable} \title{Simulation of Max-Stable Random Fields} \description{ Here, a list of models and methods for simulating max-stable random fields is given. See also \link{maxstableAdvanced} for more advanced examples. } \section{Implemented models and methods}{ Models \tabular{ll}{ \command{\link{RPbrownresnick}} \tab Brown-Resnick process using an automatic choice of the 3 \code{RPbr*} methods below \cr \command{\link{RPopitz}} \tab extremal t process \cr \command{\link{RPschlather}} \tab extremal Gaussian process \cr \command{\link{RPsmith}} \tab M3 processes \cr } Methods \tabular{ll}{ \command{\link{RPbrmixed}} \tab simulation of Brown-Resnick processes using M3 representation\cr \command{\link{RPbrorig}} \tab simulation of Brown-Resnick processes using the original definition\cr \command{\link{RPbrshifted}} \tab simulation of Brown-Resnick processes using a random shift\cr } } \references{ \itemize{ \item Kabluchko, Z., Schlather, M. & de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions \emph{Ann. Probab.} \bold{37}, 2042-2065. \item Schlather, M. (2002) Models for stationary max-stable random fields. \emph{Extremes} \bold{5}, 33-44. \item Smith, R.L. (1990) Max-stable processes and spatial extremes Unpublished Manuscript. } } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### currently not programmed \dontshow{\dontrun{ ## to do !! model <- RMfbm(alpha=1.5) x <- seq(0, 8, 0.02) z <- RFsimulate(RPbrownresnick(model), x=x, n=4) plot(z) }} \dontrun{\dontshow{ ## to do : seq(0, 10, 0.02) oben ist furchtbar langsam. Warum? }} \dontrun{\dontshow{ model <- RMball() x <- seq(0, 10, 5) # nice for x <- seq(0, 10, 0.02) z <- RFsimulate(RPsmith(model, xi=0), x, n=1000, every=1000) plot(z) hist(unlist(z@data), 150, freq=FALSE) #not correct; to do; sqrt(2) wrong curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE, col=3) }} model <- RMgauss() x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(model, xi=0), x, n=1000) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## for some more sophisticated models see maxstableAdvanced \dontshow{FinalizeExample()}} \seealso{ \link{RP}, \command{\link{RMmodel}}, \command{\link{RPgauss}}, \command{\link{RPbernoulli}}, \command{\link{maxstableAdvanced}}. } \keyword{spatial} RandomFields/man/RMball.Rd0000644000176200001440000000175513437301604015045 0ustar liggesusers\name{RMball} \alias{RMball} \title{RMball} \description{ \command{RMball} refers to the indicator function of a ball with radius 1. } \usage{ RMball(var, scale, Aniso, proj) } \arguments{ \item{var, scale, Aniso, proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \seealso{ \command{\link{RMpolygon}}, \command{\link{RMspheric}}, \command{\link{RFsimulate}}, \command{\link{RMmodel}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,len=100) model <- RMball(var=2,scale=1.5) plot(model) z <- RFsimulate(RPpoisson(model),x=x,y=x,intensity=0.1) plot(z) \dontshow{\dontrun{ model <- RPcoins(shape=RMball()) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x)) }} \dontshow{FinalizeExample()}}RandomFields/man/RFhurst.Rd0000644000176200001440000001424413437301604015266 0ustar liggesusers\name{RFhurst} \alias{RFhurst} %\alias{Hurst} %\alias{long memory dependence} \title{Hurst coefficient} \description{ The function estimates the Hurst coefficient of a process } \usage{ RFhurst(x, y = NULL, z = NULL, data, sort = TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dimen[1]/5)), log(dimen[1]), len = min(100, dimen[1]))))), fft.m = c(1, min(1000, (fft.len - 1)/10)), fft.max.length = Inf, method = c("dfa", "fft", "var"), mode = if (interactive ()) c("plot", "interactive") else "nographics", %ok pch = 16, cex = 0.2, cex.main = 0.85, printlevel = RFoptions()$basic$printlevel, height = 3.5, ...) } \arguments{ \item{x}{\argX} \item{y,z}{\argYz} \item{data}{the data} % \item{grid}{logical; determines whether the vectors \code{x}, % \code{y}, and \code{z} should be % interpreted as a grid definition, see Details. \code{grid} % does not apply for \code{T}.} \item{sort}{logical. If \code{TRUE} then the coordinates are permuted such that the largest grid length is in \code{x}-direction; this is of interest for algorithms that slice higher dimensional fields into one-dimensional sections. } \item{block.sequ}{ascending sequences of block lengths for which the detrended fluctuation analysis and the variance method are performed.} \item{fft.m}{vector of 2 integers; lower and upper endpoint of indices for the frequency which are used in the calculation of the regression line for the periodogram near the origin.} \item{fft.max.length}{if the number of points in \code{x}-direction is larger than \code{fft.max.length} then the segments of length \code{fft.max.length} are considered, shifted by \code{fft.max.length/2} (WOSA-estimator).} \item{method}{list of implemented methods to calculate the Hurst parameter; see Details} \item{mode}{character. A vector with components \code{'nographics'}, \code{'plot'} or \code{'interactive'}: %; see the Details. \describe{ \item{\code{'nographics'}}{no graphical output} \item{\code{'plot'}}{the regression line is plotted} \item{\code{'interactive'}}{the regression domain can be chosen interactively} } Usually only one mode is given. Two modes may make sense in the combination c("plot", "interactive") in which case all the results are plotted first, and then the interactive mode is called. In the interactive mode, the regression domain is chosen by two mouse clicks with the left mouse; a right mouse click leaves the plot. } \item{pch}{vector or scalar; sign by which data are plotted.} \item{cex}{vector or scalar; size of \code{pch}.} \item{cex.main}{font size for title in regression plot; only used if mode includes \code{'plot'} or \code{'interactive'}} \item{printlevel}{integer. If \code{printlevel} is 0 or 1 nothing is printed. If \code{printlevel=2} warnings and the regression results are given. If \code{printlevel>2} tracing information is given. } \item{height}{height of the graphics window} \item{...}{graphical arguments} } \details{ The function is still in development. Several functionalities do not exist - see the code itself for the current stage. The function calculates the Hurst coefficient by various methods: \itemize{ \item detrended fluctuation analysis (dfa) \item aggregated variation (var) \item periodogram or WOSA estimator (fft) } } \value{ The function returns a list with elements \code{dfa}, \code{varmeth}, \code{fft} corresponding to the three methods given in the Details. Each of the elements is itself a list that contains the following elements. \item{x}{the x-coordinates used for the regression fit} \item{y}{the y-coordinates used for the regression fit} \item{regr}{the coefficients of the \command{\link[stats]{lm}}.} \item{sm}{smoothed curve through the (x,y) points} \item{x.u}{\code{NULL} or the restricted x-coordinates given by the user in the interactive plot} \item{y.u}{\code{NULL} or y-coordinates according to \code{x.u}} \item{regr.u}{\code{NULL} or the coefficients of \command{\link[stats]{lm}} for \code{x.u} and \code{y.u}} \item{H}{the Hurst coefficient} \item{H.u}{\code{NULL} or the Hurst coefficient corresponding to the user's regression line} } \references{ % Overviews: % \itemize{ % \item % } detrended fluctuation analysis \itemize{ \item Peng, C.K., Buldyrev, S.V., Havlin, S., Simons, M., Stanley, H.E. and Goldberger, A.L. (1994) Mosaic organization of DNA nucleotides \emph{Phys. Rev. E} \bold{49}, 1685-1689 } aggregated variation \itemize{ \item Taqqu, M.S. and Teverovsky, V. (1998) On estimating the intensity of long range dependence in finite and infinite variance time series. In: Adler, R.J., Feldman, R.E., and Taqqu, M.S. \emph{A Practical Guide to Heavy Tails, Statistical Techniques an Applications.} Boston: Birkhaeuser \item Taqqu, M.S. and Teverovsky, V. and Willinger, W. (1995) Estimators for long-range dependence: an empirical study. \emph{Fractals} \bold{3}, 785-798 } periodogram \itemize{ \item Percival, D.B. and Walden, A.T. (1993) \emph{Spectral Analysis for Physical Applications: Multitaper and Conventional Univariate Techniques}, Cambridge: Cambridge University Press. \item Welch, P.D. (1967) The use of {F}ast {F}ourier {T}ransform for the estimation of power spectra: a method based on time averaging over short, modified periodograms \emph{IEEE Trans. Audio Electroacoustics} \bold{15}, 70-73. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFfractaldim}} } \keyword{ spatial }%-- one or more ... \examples{\dontshow{StartExample(reduced=50)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{.randomfields.options = options()$warn; options(warn=0)} x <- runif(1000) h <- RFhurst(1:length(x), data=x) \dontshow{options(warn = .randomfields.options)} \dontshow{FinalizeExample()}} % LocalWords: hurst gridtriple sequ exp len fft Inf dfa var pch cex WOSA regr % LocalWords: printlevel RFoptions periodogram nographics itemize varmeth % LocalWords: lm sm Schlather url ealso RMmodel RandomFields/man/RPbrownresnick.Rd0000644000176200001440000000707513437301604016645 0ustar liggesusers\name{BrownResnick} \alias{RPbrownresnick} \alias{Brown-Resnick} \alias{Brown-Resnick process} \title{Brown-Resnick process} \description{ \command{RPbrownresnick} defines a Brown-Resnick process. } \usage{ RPbrownresnick(phi, tcf, xi, mu, s) } \arguments{ \item{phi}{specifies the covariance model or variogram, see \link{RMmodel} and \link{RMmodelsAdvanced}. } \item{tcf}{the extremal correlation function; either \code{phi} or \code{tcf} must be given.} \item{xi, mu, s}{the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details.} } \details{ \GEV The functions \code{RPbrorig}, \code{RPbrshifted} and \code{RPbrmixed} perform the simulation of a Brown-Resnick process, which is defined by \deqn{Z(x) = \max_{i=1}^\infty X_i \exp(W_i(x) - \gamma^2), }{Z(x) = max_{i=1, 2, ...} X_i * exp(W_i(x) - gamma^2),} where the \eqn{X_i} are the points of a Poisson point process on the positive real half-axis with intensity \eqn{x^{-2} dx}{1/x^2 dx}, \eqn{W_i \sim W}{W_i ~ Y} are iid centered Gaussian processes with stationary increments and variogram \eqn{\gamma}{gamma} given by \code{phi}. For simulation, internally, one of the methods \command{\link{RPbrorig}}, \command{\link{RPbrshifted}} and \command{\link{RPbrmixed}} is chosen automatically. } \author{\marco; \martin} \references{ \itemize{ \item Brown, B.M. and Resnick, S.I. (1977). Extreme values of independent stochastic processes. \emph{J. Appl. Probab.} \bold{14}, 732-739. \item Buishand, T., de Haan , L. and Zhou, C. (2008). On spatial extremes: With application to a rainfall problem. \emph{Ann. Appl. Stat.} \bold{2}, 624-642. \item Kabluchko, Z., Schlather, M. and de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions \emph{Ann. Probab.} \bold{37}, 2042-2065. \item Oesting, M., Kabluchko, Z. and Schlather M. (2012) Simulation of {B}rown-{R}esnick Processes, \emph{Extremes}, \bold{15}, 89-107. } } % TO DO: ueberall diese notes einfuegen \note{Advanced options are \code{maxpoints} and \code{max_gauss}, see \command{\link{RFoptions}}. Further advanced options related to the simulation methods \command{\link{RPbrorig}}, \command{\link{RPbrshifted}} and \command{\link{RPbrmixed}} can be found in the paragraph \sQuote{Specific method options for Brown-Resnick Fields} in \command{\link{RFoptions}}.} \seealso{ \command{\link{RPbrorig}}, \command{\link{RPbrshifted}}, \command{\link{RPbrmixed}}, \command{\link{RMmodel}}, \command{\link{RPgauss}}, \command{\link{maxstable}}, \command{\link{maxstableAdvanced}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ model <- ~ RPbrownresnick(RMfbm(alpha=A), xi=0) x <- seq(0, 10, 0.2) z <- RFsimulate(model=model, x, x, n=4, A=0.9) # about 1 min on a fast machine plot(z) z <- RFsimulate(model, x=x, n=4, A=1.9) plot(z) ## basic model in Buishand, de Haan, Zhou (2008) model <- RMfbm(proj=1, alpha=1, var=0.5) + RMfbm(proj=2, alpha=1, var=0.5) x <- seq(0, 5, 0.05) z <- RFsimulate(RPbrownresnick(model, xi=0), x, x, every=1000) plot(z) }} ## for some more sophisticated models see 'maxstableAdvanced' \dontshow{FinalizeExample()}}RandomFields/man/RMcovariate.Rd0000644000176200001440000000436213437301604016105 0ustar liggesusers\name{RMcovariate} \alias{RMcovariate} \alias{RM_COVARIATE} \title{Model for covariates} \description{ The model makes covariates available. } \usage{ RMcovariate(formula=NULL, data, x, y=NULL, z=NULL, T=NULL, grid, raw, norm, addNA, factor) } \arguments{ \item{formula, data}{formula and by which the data should be modelled, similar to \link[stats]{lm}. If \code{formula} is not given, the the linear model is given by the data themselves. } \item{x,y,z,T,grid}{optional. The usual arguments as in \command{\link{RFsimulate}} to define the locations where the covariates are given. } % \item{var}{optional arguments; same meaning for any % \command{\link{RMmodel}}. If not passed, the above % covariance function remains unmodified.} % \item{factor}{vector or matrix of numerical values. % The length of the vector must match the given number of locations. % } % % \item{var}{variance, i.e. factor multiplied to the data, which can be % estimated through ML % } \item{raw}{\argRaw } \item{norm}{\argNorm} \item{addNA}{ If \code{addNA} is \code{TRUE}, then an additional (linear) factor is estimated in an estimation framework. This parameter must be set in particular when \command{RMcovariate} passes several covariates. } \item{factor}{real value. From user's point of view very much the same as setting the argument \code{var}}. } \note{ \itemize{ \item \code{c}, \code{x} also accept lists of data. However, its use is not in an advanced stage yet. } } \details{ The function interpolates (nearest neighbour) between the values. } \value{ \command{\link{RMcovariate}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMfixcov}}, \command{\link{RMmodel}}, \command{\link{RMtrend}} } \examples{\dontshow{StartExample(reduced = FALSE)} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 0.2 + (1:10) RFfctn(RMcovariate(z), 1:10) RFfctn(RMcovariate(data=z, x=1:10), c(2, 2.1, 2.5, 3)) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RFinterpolate.Rd0000644000176200001440000001553313437301604016451 0ustar liggesusers\name{RFinterpolate} \alias{RFinterpolate} \alias{kriging} \title{Interpolation methods} \description{ The function allows for different methods of interpolation. Currently, only various kinds of kriging are installed. } \usage{ RFinterpolate(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, distances, dim, data, given=NULL, params, err.model, err.params, ignore.trend = FALSE, ...) } \arguments{ \item{model,params}{\argModel} \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{data}{\argData \argDataGiven If the argument \code{x} is missing, \code{data} may contain \code{NA}s, which are then replaced through imputing. } \item{given}{\argGiven} \item{err.model,err.params}{For conditional simulation and random imputing only. \cr\argErrmodel} \item{ignore.trend}{logical. If \code{TRUE} only the covariance model of the given model is considered, without the trend part. } \item{...}{\argDots} } \note{Important options are \itemize{ \item \code{method} (overwriting the automatically detected variant of kriging) \item \code{return_variance} (returning also the kriging variance) \item \code{locmaxm} (maximum number of conditional values before neighbourhood kriging is performed) \item \code{fillall} imputing estimates location by default \item \code{varnames} and \code{coordnames} in case \code{data.frame}s are used to tell which column contains the data and the coordinates, respectively. }} \details{ In case of repeated data, they are kriged \emph{separately}; if the argument \code{x} is missing, \code{data} may contain \code{NA}s, which are then replaced by the kriged values (imputing); In case of intrinsic cokriging (intrinsic kriging for multivariate random fields) the pseudo-cross-variogram is used (cf. Ver Hoef and Cressie, 1991). } \value{ The value depends on the additional argument \code{variance.return}, see \command{\link{RFoptions}}. If \code{variance.return=FALSE} (default), \code{Kriging} returns a vector or matrix of kriged values corresponding to the specification of \code{x}, \code{y}, \code{z}, and \code{grid}, and \code{data}.\cr \code{data}: a vector or matrix with \emph{one} column\cr * \code{grid=FALSE}. A vector of simulated values is returned (independent of the dimension of the random field)\cr * \code{grid=TRUE}. An array of the dimension of the random field is returned (according to the specification of \code{x}, \code{y}, and \code{z}).\cr \code{data}: a matrix with \emph{at least two} columns\cr * \code{grid=FALSE}. A matrix with the \code{ncol(data)} columns is returned.\cr * \code{grid=TRUE}. An array of dimension \eqn{d+1}{d+1}, where \eqn{d}{d} is the dimension of the random field, is returned (according to the specification of \code{x}, \code{y}, and \code{z}). The last dimension contains the realisations. If \code{variance.return=TRUE}, a list of two elements, \code{estim} and \code{var}, i.e. the kriged field and the kriging variances, is returned. The format of \code{estim} is the same as described above. The format of \code{var} is accordingly. } \references{ Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. Cressie, N.A.C. (1993) \emph{Statistics for Spatial Data.} New York: Wiley. Goovaerts, P. (1997) \emph{Geostatistics for Natural Resources Evaluation.} New York: Oxford University Press. Ver Hoef, J.M. and Cressie, N.A.C. (1993) Multivariate Spatial Prediction. \emph{Mathematical Geology} \bold{25}(2), 219-240. Wackernagel, H. (1998) \emph{Multivariate Geostatistics.} Berlin: Springer, 2nd edition. } \author{ \martin; \marco \subsection{Author(s) of the code:}{ \martin; Alexander Malinowski; \marco} } \seealso{ \command{\link{RMmodel}}, \command{\link{RFvariogram}}, \code{\link[=RandomFields-package]{RandomFields}}, } \examples{\dontshow{StartExample()} % library(RandomFields) RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Preparation of graphics dev.new(height=7, width=16) ## creating random variables first ## here, a grid is chosen, but does not matter p <- 3:8 points <- as.matrix(expand.grid(p,p)) model <- RMexp() + RMtrend(mean=1) dta <- RFsimulate(model, x=points) plot(dta) x <- seq(0, 9, 0.25) \dontshow{if (!interactive()) x <- seq(0, 5, 1.2)} ## Simple kriging with the exponential covariance model model <- RMexp() z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Simple kriging with mean=4 and scaled covariance model <- RMexp(scale=2) + RMtrend(mean=4) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Ordinary kriging model <- RMexp() + RMtrend(mean=NA) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Co-Kriging n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) \dontshow{if (!interactive()) n <- 2} rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data data <- RFsimulate(model = model, x=x, y=y, grid=FALSE) ## introducing some NAs ... print(data) len <- length(data) data@data$variable1[1:(len / 10)] <- NA data@data$variable2[len - (0:len / 100)] <- NA print(data) plot(data) ## co-kriging x <- y <- seq(0, 50, 1) \dontshow{if (!interactive()) x <- y <- seq(0, 5, 1)} k <- RFinterpolate(model, x=x, y=y, data= data) plot(k, data) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= data) ## takes some time plot(z, data) \dontshow{\dontrun{ ## alternatively ## Intrinsic kriging model <- RMfbm(a=1) z <- RFinterpolate(krige.meth="U", model, x, x, data=dta) screen(scr <- scr+1); plot(z, dta) ## Interpolation nicht korrekt ## Intrinsic kriging with Polynomial Trend model <- RMfbm(a=1) + RMtrend(polydeg=2) z <- RFinterpolate(model, x, x, data=dta) screen(scr <- scr+1); plot(z, dta) }} \dontshow{\dontrun{ ## Universal kriging with trend as formula model <- RMexp() + RMtrend(arbit=function(X1,X2) sin(X1+X2)) + RMtrend(mean=1) z <- RFinterpolate(model, x=x, y=x, data=dta) screen(scr <- scr+1); plot(z, dta) ## Universal kriging with several arbitrary functions model <- RMexp() + RMtrend(arbit=function(x,y) x^2 + y^2) + RMtrend(arbit=function(x,y) (x^2 + y^2)^0.5) + RMtrend(mean=1) z <- RFinterpolate(model, x=x, y=x, data=dta) screen(scr <- scr+1); plot(z, dta) }} % folgender Befehl muss unbedingt drin bleiben close.screen(all = TRUE) \dontshow{while (length(dev.list()) >= 2) dev.off()} \dontshow{FinalizeExample()}} \keyword{spatial}%-- one or more ... RandomFields/man/RMplus.Rd0000644000176200001440000000366513437301604015120 0ustar liggesusers\name{RMplus} \alias{RMplus} \alias{+} \alias{RM_PLUS} \title{Addition of Random Field Models} \description{ \command{\link{RMplus}} is an additive covariance model which depends on up to 10 submodels \eqn{C_0, C_1, ..., C_9}. In general, realizations of the created \command{\link{RMmodel}} are pointwise sums of independent realizations of the submodels. In particular, if all submodels are given through a covariance function, the resulting model is defined through its covariance function, which is the sum of the submodels' covariances. Analogously, if all submodels are given through a variogram. } \usage{ RMplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj) } \arguments{ \item{C0}{an \command{\link{RMmodel}}.} \item{C1,C2,C3,C4,C5,C6,C7,C8,C9}{optional; each an \command{\link{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above model remains unmodified.} } \details{ \command{\link{RMmodel}}s can also be summed up via the \code{+}-operator, e.g. C0 + C1. The global arguments \code{var,scale,Aniso,proj} of \command{\link{RMplus}} are multiplied to the corresponding arguments of the submodels (from the right side). } \value{ \command{\link{RMplus}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmult}}, \command{\link{RMmodel}}, \command{\link{RMsum}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMplus(RMgauss(), RMnugget(var=0.1)) model2<- RMgauss() + RMnugget(var=0.1) plot(model, "model.+"=model2, type=c("p", "l"), pch=20, xlim=c(0,3)) # the same \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RPgauss.Rd0000644000176200001440000000654413437301604015261 0ustar liggesusers\name{RPgauss} \alias{RPgauss} \title{Simulation of Gaussian Random Fields} \description{ This function is used to specify a Gaussian random field that is to be simulated or estimated. Returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \usage{ RPgauss(phi, boxcox, stationary_only) } \arguments{ \item{phi}{the \command{\link{RMmodel}}.} % \item{loggauss}{logical. If \code{TRUE} then a log-Gaussian random % field is returned. Default is \code{FALSE}. % } \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{stationary_only}{Logical or NA. Used for the automatic choice of methods. \itemize{ \item \code{TRUE}: The simulation of non-stationary random fields is refused. In particular, the intrinsic embedding method is excluded and the simulation of Brownian motion is rejected. \item \code{FALSE}: Intrinsic embedding is always allowed; actually, it's the first one considered in the automatic selection algorithm. \item \code{NA}: The simulation of the Brownian motion is allowed, but intrinsic embedding is not used for translation invariant (\dQuote{stationary}) covariance models. } Default: \code{NA}. } } \value{ The function returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ In most cases, \code{RPgauss} need not be given explicitly as Gaussian random fields are assumed as default. \command{\link{RPgauss}} may not find the fastest method neither the most precise one. It just finds any method among the available methods. (However, it guesses what is a good choice.) See \command{\link{RFgetMethodNames}} for further information. Note that some of the methods do not work for all covariance or variogram models, see \code{\link{RFgetModelNames}(intern=FALSE)}. By default, all Gaussian random fields have zero mean. Simulating with trend can be done by including \command{\link{RMtrend}} in the model. \command{\link{RPgauss}} allows to simulate different classes of random fields, controlled by the wrapping model: If the submodel is a pure covariance or variogram model, i.e. of class \code{\link[=RMmodel-class]{RMmodel}}, a corresponding centered Gaussian field is simulated. Not only stationary fields but also non-stationary and anisotropic models can be used, e.g. zonal anisotropy, geometrical anisotropy, separable models, non-separable space-time models, multiplicative or nested models; see \command{\link{RMmodel}} for a list of all available models. } \me \seealso{ \link{RP}, \link{Gaussian}, \command{\link{RMmodel}}, \command{\link{RFoptions}}, \command{\link{RPbrownresnick}}, \command{\link{RPchi2}}, \command{\link{RPopitz}}, \command{\link{RPt}}, \command{\link{RPschlather}}. Do not mix up with \command{\link{RMgauss}} or \command{\link{RRgauss}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x, seed=0)) plot(RFsimulate(RPgauss(model), x=x, seed=0), col=2) ## the same \dontshow{FinalizeExample()}}RandomFields/man/RFpseudovariogram.Rd0000644000176200001440000000547713437301604017340 0ustar liggesusers\name{RFpseudovariogram} \alias{RFpseudovariogram} \title{Pseudovariogram} \description{ Calculates the theoretical and empirical Pseudovariogram. } \usage{ RFpseudovariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} \item{data}{\argData} \item{bin}{\argBin} \item{phi}{\argPhi} \item{theta}{\argTheta} \item{deltaT}{\argDeltaT} \item{vdim}{\argVdim} } \details{ \command{\link{RFpseudovariogram}} computes the empirical pseudovariogram for given (multivariate) spatial data. %The empirical % prsepseudovariogram of two random fields \eqn{X}{X} and \eqn{Y}{Y} is given by %2 \deqn{\gamma(r):=\frac{1}{2N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})-X(t_{j}))(Y(t_{i})-Y(t_{j}))}{\gamma(r):=1/2N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} (X(t_{i})-X(t_{j}))(Y(t_{i})-Y(t_{j}))} %where \eqn{t_{i,j}:=t_{i}-t_{j}}{t_{i,j}:=t_{i}-t_{j}}, and where \eqn{N(r)}{N(r)} denotes the number of pairs of data points with distancevector %\eqn{t_{i,j}=r}{t_{i,j}=r}. The spatial coordinates \code{x}, \code{y}, \code{z} should be vectors. For random fields of spatial dimension \eqn{d > 3} write all vectors as columns of matrix x. In this case do neither use y, nor z and write the columns in \code{gridtriple} notation. If the data is spatially located on a grid a fast algorithm based on the fast Fourier transformed (fft) will be used. As advanced option the calculation method can also be changed for grid data (see \command{\link{RFoptions}}.) } \value{ an objects of class \command{\link[=RFempVariog-class]{RFempVariog}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \me \seealso{ \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFcov}}, \command{\link{RFmadogram}}. \command{\link{RFvariogram}}, } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=2) emp.vario <- RFpseudovariogram(data=z) plot(emp.vario, model=model) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMmodelsSpaceTime.Rd0000644000176200001440000000560713437301604017211 0ustar liggesusers\name{RMmodelsSpacetime} \alias{RMmodelsSpacetime} \alias{RMmodelsSpaceTime} \alias{space-time} \title{Space-time Covariance Models} \description{ Here, a collection of implemented space-time models is given. } \details{ \bold{Stationary space-time models} Here, most of the models are composed models (operators). Note that in space-time modelling the argument \code{proj} may also take the values \code{"space"} for the projection on the space and \code{"time"} for the projection onto the time axis. \tabular{ll}{ separable models \tab are easily constructed using \command{\link[=RMplus]{+}}, \command{\link[=RMmult]{*}}, and \link[=RMmodels]{proj}, see also the example below \cr \command{\link{RMave}} \tab space-time moving average model \cr \command{\link{RMcoxisham}} \tab Cox-Isham model \cr \command{\link{RMcurlfree}} \tab curlfree (spatial) field (stationary and anisotropic) \cr \command{\link{RMdivfree}} \tab divergence free (spatial) vector-valued field (stationary and anisotropic) \cr \command{\link{RMgennsst}} \tab generalization of Gneiting's non-separable space-time model \cr \command{\link{RMiaco}} \tab non-separable space-time model \cr % obsolete -- included by Cauchy --- should be given by an example \command{\link{RMmastein}} \tab Ma-Stein model \cr \command{\link{RMnsst}} \tab Gneiting's non-separable space-time model \cr \command{\link{RMstein}} \tab Stein's non-separable space-time model \cr \command{\link{RMstp}} \tab Single temporal process \cr \command{\link{RMtbm}} \tab Turning bands operator } } \references{ \itemize{ \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. } } \seealso{\command{\link{RFformula}}, \link{RM}, \command{\link{RMmodels}}, \command{\link{RMmodelsAdvanced}}. } \author{Alexander Malinowski; \martin} \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## multiplicative separable model with exponential model in space ## and Gaussian in time model <- RMexp(proj = "space") * RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) plot(z) ## additive separable model with exponential model in space ## and Gaussian in time. The structure is getting rather simple, ## see the function stopifnot below model <- RMexp(proj = "space") + RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) stopifnot(sum(abs(apply(apply(z, 1, diff), 1, diff))) < 1e-14) plot(z) \dontshow{FinalizeExample()} } RandomFields/man/RMwave.Rd0000644000176200001440000000336113437301604015070 0ustar liggesusers\name{RMwave} \alias{RMwave} \alias{RMcardinalsine} \title{Wave Covariance Model / Cardinal Sine} \description{ \command{\link{RMwave}} is a stationary isotropic covariance model, which is valid only for dimensions \eqn{d \le 3}{d \le 3}. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = sin(r)/r 1_{r>0} + 1_{r=0} .}{C(r)=sin(r)/r 1_{r>0} + 1_{r=0} .} It is a special case of \command{\link{RMbessel}}. } \usage{ RMwave(var, scale, Aniso, proj) RMcardinalsine(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model is only valid for dimensions \eqn{d \le 3}{d \le 3}. It is a special case of \command{\link{RMbessel}} for \eqn{\nu = 0.5}{\nu = 0.5}. This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92). } \value{ \command{\link{RMwave}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. } } \me \seealso{ \command{\link{RMbessel}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMwave(scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RM.Rd0000644000176200001440000000415413437301604014206 0ustar liggesusers\name{RMmodels Overview} \alias{RM} \title{Overview over classes of \code{RMmodels}} \description{ Various classes of models \code{RMxxx} are implemented in RandomFields, that have their own man pages. Here, an overview over these man pages are given. } \section{Man pages}{ Beginners should start with \link{RMmodels}, then go for \link{RMmodelsAdvanced} if more information is needed. \tabular{ll}{ \link{RMmodels} \tab general introduction and a collection of simple models \cr \link{RMmodelsAdvanced} \tab includes more advanced stationary and isotropic models, variogram models, non-stationary models and trend models \cr \link{Bayesian} \tab hierarchical models \cr \link{RMmodelsMultivariate} \tab multivariate covariance models and multivariate trend models \cr \link{RMmodelsNonstationary} \tab non-stationary covariance models \cr \link{RMmodelsSpaceTime} \tab space-time covariance models \cr \link{Spherical models} \tab models based on the polar coordinate system, usually used in earth models \cr \link{Tail correlation functions} \tab models related to max-stable random fields \cr \link{trend modelling} \tab how to pass trend specifications \cr \link[=RFcalc]{Mathematical functions} \tab simple mathematical functions that are typically used to build non-stationary covariance models and arbitrary trends \cr \link{RMmodelsAuxiliary} \tab rather specialized models, most of them not having positive definiteness property, but used internally in certain simulation algorithms, for instance. \cr % \link{RMmodels} \tab % \cr } } \seealso{ \link{RC}, \link{RR}, \link{RF}, \link{R.} } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="positive definite", domain="single variable", isotropy="isotropic", operator=!FALSE) ## RMmodel.Rd \dontshow{FinalizeExample()}} RandomFields/man/RRrectangular.Rd0000644000176200001440000000626013437301604016443 0ustar liggesusers\name{RRrectangular} \alias{RRrectangular} \title{Random scaling used with balls} \description{ Approximates an isotropic decreasing density function by a density function that is isotropic with respect to the \eqn{l_1} norm. } \usage{ RRrectangular(phi, safety, minsteplen, maxsteps, parts, maxit, innermin, outermax, mcmc_n, normed, approx, onesided) } \arguments{ \item{phi}{a shape function; it is the user's responsibility that it is non-negative. See Details.} \item{safety, minsteplen, maxsteps, parts, maxit, innermin, outermax, mcmc_n}{ Technical arguments to run an algorithm to simulate from this distribution. See \command{\link{RFoptions}} for the default values. } \item{normed}{logical. If \code{FALSE} then the norming constant \eqn{c} in the Details is set to \eqn{1}. This affects the values of the density function, the probability distribution and the quantile function, but not the simulation of random variables. } \item{approx}{logical. Default is \bold{\code{TRUE}}. If \code{TRUE} the isotropic distribution with respect to the \eqn{l_1} norm is returned. If \code{FALSE} then the exact isotropic distribution with respect to the \eqn{l_2} norm is simulated. Neither the density function, nor the probability distribution, nor the quantile function will be available if \code{approx=TRUE}. } \item{onesided}{logical. Only used for univariate distributions. If \code{TRUE} then the density is assumed to be non-negative only on the positive real axis. Otherwise the density is assumed to be symmetric. } } \details{ This model defines an isotropic density function $f$ with respect to the \eqn{l_1} norm, i.e. \eqn{f(x) = c \phi(\|x\|_{l_1})} with some function \eqn{\phi}. Here, \eqn{c} is a norming constant so that the integral of \eqn{f} equals one. In case that \eqn{\phi} is monotonically decreasing then rejection sampling is used, else MCMC. The function \eqn{\phi} might have a polynomial pole at the origin and asymptotical decreasing of the form \eqn{x^\beta exp(-x^\delta)}. } \value{ \command{\link{RRrectangular}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RRdistr}}, \command{\link{RRgauss}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulation of Gaussian variables (in a not very straightforward way): distr <- RRrectangular(RMgauss(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) x <- seq(-10, 10, 0.1) lines(x, dnorm(x, sd=sqrt(0.5))) #creation of random variables whose density is proportional # to the spherical model: distr <- RRrectangular(RMspheric(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) \dontshow{StartExample(reduced=FALSE, save.seed=FALSE)} x <- seq(-10, 10, 0.01) lines(x, 4/3 * RFcov(RMspheric(), x)) \dontshow{FinalizeExample()}} RandomFields/man/RFlinearpart.Rd0000644000176200001440000000372313437301604016262 0ustar liggesusers\name{RFlinearpart} \alias{RFlinearpart} \title{Linear part of \command{\link{RMmodel}}} \description{ \command{\link{RFlinearpart}} returns the linear part of a model } \usage{ RFlinearpart(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, params, distances, dim, set=0, ...) } \arguments{ \item{model,params}{\argModel} \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{data}{\argData} \item{set}{integer. See section Value for details.} \item{...}{\argDots} } \note{ In the linear part of the model specification the parameters that are NA must be the first model part. I.e. \code{NA * sin(R.p(new="isotropic")) + NA + R.p(new="isotropic")} is OK, but not \code{sin(R.p(new="isotropic")) * NA + NA + R.p(new="isotropic")} } \value{ \command{\link{RFlinearpart}} returns a list of three components, \code{Y}, \code{X}, \code{vdim} returning the deterministic trend, the design matrix, and the multivariability, respectively. If \code{set} is positive, \code{Y} and \code{X} contain the values for the \code{set}-th set of coordinates. Else, \code{Y} and \code{X} are both lists containing the values for all the sets. } \me \seealso{ \link{Bayesian}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFlikelihood}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- RMexp(var=2, scale=1) + trend print(RFlinearpart(model, x=x)) ## only a deterministic part trend <- NA * sin(R.p(new="isotropic")) + NA + R.p(new="isotropic") / pi model <- RMexp(var=NA, scale=NA) + trend print(RFlinearpart(model, x=x)) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMfractgauss.Rd0000644000176200001440000000335513437301604016273 0ustar liggesusers\name{RMfractgauss} \alias{RMfractgauss} \title{Fractal Gaussian Model Family} \description{ \command{\link{RMfractgauss}} is a stationary isotropic covariance model. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = 0.5 ((r+1)^{\alpha}-2r^{\alpha}+|r-1|^{\alpha})}{C(r) = 0.5 ((r+1)^(\alpha)-2r^(\alpha)+|r-1|^(\alpha))} with \eqn{0 < \alpha \le 2}. It can only be used for one-dimensional random fields. } \usage{ RMfractgauss(alpha,var, scale, Aniso, proj) } \arguments{ \item{alpha}{ \eqn{0 < \alpha \le 2}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The model is only valid for dimension \eqn{d = 1}{d = 1 }. It is the covariance function for the fractional Gaussian noise with self-affinity index (Hurst parameter) \eqn{H=\alpha /2}{H=\alpha /2} with \eqn{0 < \alpha \le 2}{0 < \alpha \le 2}. } \value{ \command{\link{RMfractgauss}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractgauss(alpha=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/BRmethods.Rd0000644000176200001440000001027213437301604015555 0ustar liggesusers\name{Brown-Resnick-Specific} \alias{BRmethods} \alias{RPbrmixed} \alias{RPbrorig} \alias{RPbrshifted} \alias{RPloggaussnormed} \title{Simulation methods for Brown-Resnick processes} \description{ These models define particular ways to simulate Brown-Resnick processes. } \usage{ RPbrmixed(phi, tcf, xi, mu, s, meshsize, vertnumber, optim_mixed, optim_mixed_tol,lambda, areamat, variobound) RPbrorig(phi, tcf, xi, mu, s) RPbrshifted(phi, tcf, xi, mu, s) RPloggaussnormed(variogram, prob, optimize_p, nth, burn.in, rejection) } \arguments{ \item{phi,variogram}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated.} \item{tcf}{the extremal correlation function; either \code{phi} or \code{tcf} must be given.} \item{xi, mu, s}{the shape parameter, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details.} \item{lambda}{positive constant factor in the intensity of the Poisson point process used in the M3 representation, cf. Thm. 6 and Remark 7 in Oesting et. al (2012); can be estimated by setting \code{optim_mixed} if unknown. Default value is 1.} \item{areamat}{vector of values in \eqn{[0,1]}. The value of the \eqn{k}{k}th component represents the portion of processes whose maximum is located at a distance \eqn{d} with \eqn{k-1 \leq d < k}{k-1 <= d < k} from the origin taken into account for the simulation of the shape function in the M3 representation. \code{areamat} can be used for isotropic models only; can be optimized by setting \code{optim_mixed} if unknown. Default value is 1.} \item{meshsize, vertnumber, optim_mixed, optim_mixed_tol, variobound}{further arguments for simulation via the mixed moving maxima (M3) representation; see \code{\link{RFoptions}}.} \item{prob}{to do } \item{optimize_p}{to do } \item{nth}{to do } \item{burn.in}{to do } \item{rejection}{to do } } \details{ The argument \code{xi} is always a number, i.e. \eqn{\xi} is constant in space. In contrast, \eqn{\mu} and \eqn{s} might be constant numerical values or given an \code{\link{RMmodel}}, in particular by an \code{\link{RMtrend}} model. The functions \code{RPbrorig}, \code{RPbrshifted} and \code{RPbrmixed} simulate a Brown-Resnick process, which is defined by \deqn{Z(x) = \max_{i=1}^\infty X_i \exp(W_i(x) - \gamma), }{Z(x) = max_{i=1, 2, ...} X_i * exp(W_i(x) - gamma),} where the \eqn{X_i} are the points of a Poisson point process on the positive real half-axis with intensity \eqn{x^{-2} dx}{1/x^2 dx}, \eqn{W_i \sim W}{W_i ~ Y} are iid centered Gaussian processes with stationary increments and variogram \eqn{\gamma}{gamma} given by \code{model}. The functions correspond to the following ways of simulation: \describe{ \item{\code{RPbrorig}}{simulation using the original definition (method 0 in Oesting et al., 2012)} \item{\code{RPbrshifted}}{simulation using a random shift (similar to method 1 and 2)} \item{\code{RPbrmixed}}{simulation using M3 representation (method 4)} } } \value{ The functions return an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Oesting, M., Kabluchko, Z. and Schlather M. (2012) Simulation of {B}rown-{R}esnick Processes, \emph{Extremes}, \bold{15}, 89-107. }} \note{Advanced options for \code{RPbroriginal} and \code{RPbrshifted} are \code{maxpoints} and \code{max_gauss}, see \command{\link{RFoptions}}.} \author{\marco; \martin} \examples{\dontshow{StartExample()} # RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again % TO DO ## currently does not work \dontshow{\dontrun{ model <- RPbrshifted(RMfbm(alpha=1.5), xi=0) x <- 0:10 z <- RFsimulate(model=model, x=x, y=x, n=4) plot(z) }} \dontshow{FinalizeExample()} } \seealso{ \command{\link{RPbrownresnick}}, \command{\link{RMmodel}}, \command{\link{RPgauss}}, \command{\link{maxstable}}, \command{\link{maxstableAdvanced}}. } \keyword{methods} RandomFields/man/papers.S10.Rd0000644000176200001440000000633013437301604015522 0ustar liggesusers\name{S10} \alias{S10} %\alias{Papers} %\alias{schlather} %\alias{Schlather} \title{On some covariance models based on normal scale mixtures} \description{ Here, the code of the paper on \sQuote{On some covariance models based on normal scale mixtures} is given. } \me \references{ \itemize{ \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### Example 10 in Schlather (2010). ## The field below has more than 80 million points. So the simulation ## takes a while y <- x <- seq(0, 10, len=256) ## currently does not work T <- c(0, 0.02, 1275) col <- c(topo.colors(300)[1:100], cm.colors(300)[c((1:50) * 2, 101:150)]) %\dontshow{if(RFoptions()$internal$examples_red){warning("reduced x,y,T") y <- x <- seq(0, 10, len=5) T <- c(0, 0.02, 4) %}} model <- RMcoxisham(mu=c(1, 1), D=matrix(nr=2, c(1, 0.5, 0.5, 1)), RMwhittle(nu=1)) z <- RFsimulate(model, x, y, T=T, sp_lines=1500, every=10) plot(z, MARGIN.slices=3, col=col) plot(z, MARGIN.movie=3) # add 'file="ci.avi"' to get it stored \dontshow{\dontrun{ ### Example 13 in Schlather (2010) y <- x <- seq(0, 10,len = 256) T <- c(0, 0.02, 1275) col <- c(topo.colors(300)[1:100], cm.colors(300)[c((1:50) * 2, 101:150)]) \dontshow{if(RFoptions()$internal$examples_red){warning("reduced x,y,T"); y <- x <- seq(0, 10,len = 10) T <- c(0, 0.02, 4) }} model <- RMave(A = matrix(nc=2,c(0.5, 0, 0, 1)), z= c(2,0), RMwhittle(nu=1)) z <- RFsimulate(model, x, y, T=T, every = 10, trials=2, force=TRUE, maxmem=16777216*8) plot(z) }} \dontshow{\dontrun{ basicname <- "moving" Plot(basicname, x, y, z, col=col, T=T) save(file=paste(basicname, "/", basicname, ".dat", sep=""), z) # OK }} \dontshow{\dontrun{ ### Example 16 in Schlather (2010) intens <- 1000 ## takes a huge amount of time; take smaller values len <- 81 \dontshow{if(RFoptions()$internal$examples_red){warning("modified intens & len");intens<-3;len<-4}} y <- x <- seq(-3, 3, len=len) T <- seq(0, 0.075, len=len) col <- c(topo.colors(300)[1:100], cm.colors(300)[c((1:50) * 2, 101:150)]) \dontshow{if(RFoptions()$internal$examples_red){warning("reduced 'intens'"); intens<-3}} model <- RMstp(M=matrix(nc=3, rep(0, 9)), S=RMetaxxa(E=c(1, 1, 1), alpha = -2 * pi, A=t(matrix(nc=3, c(2, 0, 0, 1, 1 , 0, 0, 0, 0)))), Aniso = RMrotation(phi= -2 * pi), phi = RMwhittle(nu = 1) ) z <- RFsimulate(model, x, x, z=T, me="coin", every = 10, mpp.intens=intens, mpp.p = 0.1, mpp.beta=3.5, mpp.plus = 8, print=3) zlim <- c(-3.5, 3.5) time <- dim(z)[3] for (i in 1:time) {Print(i);image(x, y, z[,,i], add=i>1, col=col, zlim=zlim)} }} \dontshow{\dontrun{ basicname <- "cyclone" Plot(basicname, x, y, z, col=col, T=T, pixels=256, zi=0.5 + dim(z)[2]/2, speed=0.2, zlim=zlim) save(file=paste(basicname, "/", basicname, ".dat", sep=""), z) # OK }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMmult.Rd0000644000176200001440000000434713437301604015114 0ustar liggesusers\name{RMmult} \alias{RMmult} \alias{*} \alias{RM_MULT} \title{Multiplication of Random Field Models} \description{ \command{\link{RMmult}} is a multivariate covariance model which depends on up to 10 submodels \eqn{C_0, C_1, ..., C_9}. In general, realizations of the created \command{\link{RMmodel}} are pointwise products of independent realizations of the submodels. In particular, if all submodels are given through a covariance function, the resulting model is defined through its covariance function, which is the product of the submodels' covariances. } \usage{ RMmult(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj) } \arguments{ \item{C0}{an \command{\link{RMmodel}}.} \item{C1,C2,C3,C4,C5,C6,C7,C8,C9}{optional; each an \command{\link{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above model remains unmodified.} } \details{ \command{\link{RMmodel}}s can also be multiplied via the \code{*}-operator, e.g. C0 * C1. The global arguments \code{scale,Aniso,proj} of \command{\link{RMmult}} are multiplied to the corresponding argument of the submodels (from the right side). E.g., \cr \code{RMmult(Aniso=A1, RMexp(Aniso=A2), RMspheric(Aniso=A3))} \cr equals \cr \code{RMexp(Aniso=A2 \%*\% A1) * RMspheric(Aniso=A3 \%*\% A1)} In case that all submodels are given through a covariance function, the global argument \code{var} of \command{\link{RMmult}} is multiplied to the product covariance of \command{\link{RMmult}}. } \value{ \command{\link{RMmult}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMplus}}, \command{\link{RMmodel}}, \command{\link{RMprod}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # separable, multiplicative model model <- RMgauss(proj=1) * RMexp(proj=2, scale=5) z <- RFsimulate(model=model, 0:10, 0:10, n=4) plot(z) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMcubic.Rd0000644000176200001440000000313213437301604015207 0ustar liggesusers\name{RMcubic} \alias{RMcubic} \title{Cubic Covariance Model} \description{ \command{\link{RMcubic}} is a stationary isotropic covariance model which is only valid for dimensions \eqn{d \le 3 }{d \le 3 }. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (1 - 7r^2 + 8.75 r^3 - 3.5 r^5 + 0.75 r^7) 1_{[0,1]}(r).}{C(r) = (1 -7 r^(2) + 8.75 r^3 - 3.5 r^5 + 0.75 r^7) 1_{[0,1]}(r).} } \usage{ RMcubic(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The model is only valid for dimensions \eqn{d \le 3 }{d \le 3 }. It is a 2 times differentiable covariance function with compact support (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 84). } \value{ \command{\link{RMcubic}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcubic() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMnugget.Rd0000644000176200001440000000354613437301604015424 0ustar liggesusers\name{RMnugget} \alias{RMnugget} \alias{RM_NUGGET} \title{Nugget Effect Covariance Model} \description{ \command{\link{RMnugget}} is a multivariate stationary isotropic covariance model called \dQuote{nugget effect}. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given for \eqn{i,j} in \eqn{1,...,}\code{vdim} by \deqn{C_{ij}(r) = \delta_{ij} 1_{0}(r),} where \eqn{\delta_{ij}=1} if \eqn{i=j} and \eqn{\delta_{ij}=0} otherwise. } \usage{ RMnugget(tol, vdim, var, Aniso, proj) } \arguments{ \item{tol}{Only for advanced users. See \command{\link{RPnugget}}.} \item{vdim}{Must be set only for multivariate models (advanced).} \item{var}{optional argument; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} \item{Aniso,proj}{(zonal modelling and repeated measurements(advanced)); see \command{\link{RPnugget}} for details. } } \details{ The nugget effect belongs to Gaussian white noise and is used for modeling measurement errors or to model spatial \sQuote{nuggets}. } \value{ \command{\link{RMnugget}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RPnugget}} (advanced users). } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) \dontshow{FinalizeExample()}} RandomFields/man/RMeaxxa.Rd0000644000176200001440000000252313437301604015233 0ustar liggesusers\name{RMeaxxa} \alias{RMeaxxa} \alias{RMetaxxa} \title{Special models for rotation like fields} \description{ \command{RMeaxxa} and \command{RMetaxxa} define the auxiliary functions \deqn{f(h) = h^\top A A^\top h + diag(E)}{C(h) = h^T A A^T h + diag(E)} and \deqn{f(h) = h^\top A R R A^\top h + diag(E)}{C(h) = h^T A R R^R A^T h + diag(E),} respectively. } \usage{ RMeaxxa(E, A) RMetaxxa(E, A, alpha) } \arguments{ \item{E}{m-variate vector of positive values} \item{A}{\eqn{m\times k}{m x k} matrix} \item{alpha}{angle for the rotation matrix \eqn{R}} } \details{ \command{\link{RMeaxxa}} is defined in space and returns an m-variate model. \command{\link{RMetaxxa}} is a space-time model with two spatial dimensions. The matrix R is a rotation matrix with angle \eqn{\beta t} where \eqn{t} is the time component. } \value{ \command{\link{RMeaxxa}} and \command{\link{RMetaxxa}} return an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RMmodel}}, \link{S10} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} # see S10 \dontshow{FinalizeExample()}} RandomFields/man/RPopitz.Rd0000644000176200001440000000321513437301604015274 0ustar liggesusers\name{Extremal t} \alias{RPopitz} \alias{extremal t} \alias{extremal t process} \title{Extremal t process} \description{ \command{RPopitz} defines an extremal t process. } \usage{ RPopitz(phi, xi, mu, s, alpha) } \arguments{ \item{phi}{an \command{\link{RMmodel}}; covariance model for a standardized Gaussian random field, or the field itself. } \item{xi,mu,s}{the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. } \item{alpha}{originally referred to the \eqn{\alpha}-Frechet marginal distribution, see the original literature for details. } } \details{\GEV } \me \references{ \itemize{ \item Davison, A.C., Padoan, S., Ribatet, M. (2012). Statistical modelling of spatial extremes. \emph{Stat. Science} \bold{27}, 161-186. \item Opitz, T. (2012) A spectral construction of the extremal t process. \emph{arxiv} \bold{1207.2296}. } } \seealso{ \command{\link{RMmodel}}, \command{\link{RPgauss}}, \command{\link{maxstable}}, \command{\link{maxstableAdvanced}}. } \keyword{spatial} \examples{\dontshow{StartExample()} ## sorry, does not work savely yet \dontshow{\dontrun{ RFoptions(seed=0, xi=0) ## seed=0: *ANY* simulation will have the random xseed 0; set ## RFoptions(seed=NA) to make them all random again ## xi=0: any simulated max-stable random field has extreme value index 0 x <- seq(0, 2, 0.01) model <- RPopitz(RMgauss(), alpha=2) z1 <- RFsimulate(model, x) plot(z1, type="l") }} \dontshow{FinalizeExample()}} RandomFields/man/RMoesting.Rd0000644000176200001440000000350213437301604015573 0ustar liggesusers\name{RMflatpower} \alias{RMflatpower} \title{Variogram Model Similar to Fractal Brownian Motion} \description{ \command{\link{RMflatpower}} is an intrinsically stationary isotropic variogram model. The corresponding centered semi-variogram only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{\gamma(r) = r^2 / ( 1 + r^2)^\alpha} where \eqn{\alpha \in (0,1]}{0 < \alpha \le 1}.\cr For related models see \command{\link{RMgenfbm}}. } \usage{ RMflatpower(alpha, var, scale, Aniso, proj) } \arguments{ \item{alpha}{numeric in \eqn{(0,1]}; refers to the fractal dimension of the process} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above variogram remains unmodified.} } \details{ The model is always smooth at the origin. The parameter \eqn{\alpha}{\alpha} only gives the tail behaviour and satisfies \eqn{\alpha \in (0,1]}{0 < \alpha \le 1}. The variogram is unbounded and belongs to a non-stationary process with stationary increments. } \value{ \command{\link{RMflatpower}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Oesting, M., Schlather, M., and Friederichs, P. (2014) Conditional Modelling of Extreme Wind Gusts by Bivariate {Brown-Resnick} Processes \emph{arxiv} \bold{1312.4584}. } } \me \seealso{ \command{\link{RMgenfbm}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMflatpower(alpha=0.5) x <- seq(0, 10, 0.1) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMqam.Rd0000644000176200001440000000462013437301604014703 0ustar liggesusers\name{RMqam} \alias{RMqam} \alias{RMqam} \title{Quasi-arithmetic mean} \description{ \command{\link{RMqam}} is a univariate stationary covariance model depending on a submodel \eqn{\phi}{phi} such that \eqn{\psi(\cdot) := \phi(\sqrt(\cdot))}{psi( . ) := phi(sqrt( . ))} is completely monotone, and depending on further stationary covariance models \eqn{C_i}. The covariance is given by \deqn{C(h) = \phi(\sqrt(\sum_i \theta_i (\phi^{-1}(C_i(h)))^2))}{C(h) = phi(sqrt(sum_i theta_i (phi^{-1}(C_i(h)))^2))} } \usage{ RMqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj) } \arguments{ \item{phi}{a valid covariance \command{\link{RMmodel}} that is a normal scale mixture. See, for instance, \cr \code{\link{RFgetModelNames}(monotone="normal mixture")}. } \item{C1, C2, C3, C4, C5, C6, C7, C8, C9}{optional further univariate stationary \command{\link{RMmodel}}s} \item{theta}{a vector with positive entries} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ Note that \eqn{\psi(\cdot) := \phi(\sqrt(\cdot))}{psi( . ) := phi(sqrt( . ))} is completely monotone if and only if \eqn{\phi}{phi} is a valid covariance function for all dimensions, e.g. \command{\link{RMstable}}, \command{\link{RMgauss}}, \command{\link{RMexponential}}. Warning: \code{RandomFields} cannot check whether the combination of \eqn{\phi}{phi} and \eqn{C_i} is valid. } \value{ \command{\link{RMqam}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Porcu, E., Mateu, J. & Christakos, G. (2007) Quasi-arithmetic means of covariance functions with potential applications to space-time data. Submitted to Journal of Multivariate Analysis. } } \me \seealso{ \command{\link{RMmqam}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqam(phi=RMgauss(), RMexp(), RMgauss(), theta=c(0.3, 0.7), scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}} RandomFields/man/RMcauchytbm.Rd0000644000176200001440000000272013437301604016103 0ustar liggesusers\name{RMcauchytbm} \alias{RMcauchytbm} \title{Modifications of the Cauchy Family Covariance Model} \description{ \code{\link{RMcauchytbm}()} is a shortcut of \command{\link{RMtbm}(\link{RMgencauchy}())} and is given here for downwards compatibility. } \usage{ RMcauchytbm(alpha, beta, gamma, var, scale, Aniso, proj) } \arguments{ \item{alpha,beta}{See \command{\link{RMgencauchy}}.} \item{gamma}{is the same as \code{fulldim} in \command{\link{RMtbm}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMcauchytbm}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. } } \me \seealso{ \command{\link{RMcauchy}}, \command{\link{RMgencauchy}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchytbm(alpha=1, beta=1, gamma=3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMspheric.Rd0000644000176200001440000000332213437301604015560 0ustar liggesusers\name{RMspheric} \alias{RMspheric} \title{The Spherical Covariance Model} \description{ \command{\link{RMspheric}} is a stationary isotropic covariance model which is only valid up to dimension 3. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = \left(1 - \frac{3}{2} r + \frac{1}{2} r^3\right) 1_{[0,1]}(r)}{C(r) = (1 - 1.5 r + 0.5 r^3) 1_{[0,1]}(r).} } \usage{ RMspheric(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This covariance model is valid only for dimensions less than or equal to 3. The covariance function has a finite range. } \value{ \command{\link{RMspheric}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. } \me \note{Although this model is valid on a sphere, do not mix up this model with valid models on a sphere; see \link{spherical models} for a list of the latter.} \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \link{spherical models}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMspheric() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RP.Rd0000644000176200001440000000250413437301604014206 0ustar liggesusers\name{RPprocess} \alias{RP} \alias{RPmodel} \alias{RPmodels} \alias{RPprocess} \alias{RPprocesses} \title{Models for classes of random fields (RP commands)} \description{ Here, all classes of random fields are described that can be simulated. } \section{Implemented processes}{ \tabular{ll}{ Gaussian Random Fields \tab see \link{Gaussian}\cr Max-stable Random Fields \tab see \link{Maxstable}\cr Other Random Fields \tab \link[=RPbernoulli]{Binary field} \cr \tab \link[=RPchi2]{chi2 field}\cr \tab \link[=RPpoisson]{composed Poisson} (shot noise, random coin) \cr \tab \link[=RPt]{t field}\cr } } \seealso{ \link{RC}, \link{RR}, \link{RM}, \link{RF}, \link{R.} } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RMexp() ## a Gaussian field with exponential covariance function z <- RFsimulate(model, x) plot(z) ## a binary field obtained as a thresholded Gaussian field b <- RFsimulate(RPbernoulli(model), x) plot(b) sum( abs((z@data$variabl1 >=0 ) - b@data$variable1)) == 0 ## TRUE, ## i.e. RPbernoulli is indeed a thresholded Gaussian process \dontshow{FinalizeExample()}} RandomFields/man/RFgetModelInfo.Rd0000644000176200001440000001502613437301604016474 0ustar liggesusers\name{RFgetModelInfo} \alias{RFgetModelInfo} \alias{RFgetModelInfo_register} \alias{RFgetModelInfo_model} %\alias{GetModelInfo} %\alias{GetModel} %- Also NEED an '\alias' for EACH other topic documented here. \title{Information on RMmodels} \description{ The function returns information about an \link{RMmodel}, either internal information when used in simulations, for instance, or general information } \usage{ RFgetModelInfo(...) RFgetModelInfo_register(register, level = 1, spConform = RFoptions()$general$spConform, which.submodels = c("user", "internal", "call+user", "call+internal", "user.but.once", "internal.but.once", "user.but.once+jump", "internal.but.once+jump", "all"), modelname = NULL, origin = "original") RFgetModelInfo_model(model, params, dim = 1, Time = FALSE, kernel = FALSE, exclude_trend = TRUE, ...) } \arguments{ \item{...}{See the argument of \command{RFgetModelInfo_register} and \command{RFgetModelInfo_model}; \command{RFgetModelInfo} is an abbreviation for the other two functions.} \item{register}{\eqn{0,...,21} or an evaluating function, e.g. \command{\link{RFsimulate}}. Place where intermediate calculations are stored. See also section \code{Registers} in \command{\link{RFoptions}}. } \item{level}{integer [0...5]; level of details, i.e. the higher the number the more details are given. } % \item{max.elements}{integer; since \command{\link{RFgetModelInfo}} % might be a dump of simulation that needs a huge amount of % memory and since all entries are copied, the maximal amount % of available memory might be easily exceeded. Therefore, % only the size of the critical parts are returned and not the % vector or matrix itself, if the number of elements exceeds % \code{max.elements}. % } \item{spConform}{see \command{\link{RFoptions}} } \item{which.submodels}{ Internally, the sub-models are represented in two different ways: \sQuote{internal} and \sQuote{user}. The latter is very close to the model defined by the user. Most models have a leading internal model. The values \code{"call+user"} and \code{"call+internal"} also return this leading model if existent. The values \code{"user.but.once"}, \code{"internal.but.once"} \code{"user.but.once"} returns the user path of the internal model following the leading model. \code{"internal.but.once"} would return the internal path of the user model following the leading model, but this path should never exist. So as all the other options if a certain direction does not exist, the alternative path is taken. The values \code{"user.but.once+jump"}, \code{"internal.but.once+jump"} same as \code{"user.but.once"} and \code{"internal.but.once"}, except that the first submodel below the leading model is not given. The value \code{"all"} returns the whole tree of models (very advanced). } \item{modelname}{ string. If \code{modelname} is given then it returns the first appearance of the covariance model with name \code{modelname}. If \code{meth} is given then the model within the method is returned. } \item{model,params}{\argModel Here, \code{NA}s should be placed where information on the parameters is desired.. } \item{dim}{positive integer. Spatial dimension. } \item{Time}{logical. Should time be considered, too? } \item{kernel}{logical. Should the model be considered as a kernel? } \item{exclude_trend}{logical. Currently, only \code{TRUE} is available. } \item{origin}{\argOrigin} } \details{ \command{RFgetModelInfo} branches either into \command{RFgetModelInfo_register} or \command{RFgetModelInfo_model}, depending on the type of the \emph{first} argument. The latter two are usually not called by the user. \command{RFgetModelInfo} has three standard usages: \itemize{ \item \code{RFgetModelInfo()} returns internal information on the last call of an \code{\link{RF}} function. \item \code{RFgetModelInfo(RFfunction)} returns internal information on the last call of \code{\link{RF}function}. \item \code{RFgetModelInfo(RMmodel)} returns general information on \code{\link{RMmodel}} } Whereas \command{RFgetModelInfo()} can return detailed internal information, \command{\link{RFgetModel}} returns a model that can be re-used by the user. } \note{ Put \code{Storing=TRUE}, see \command{\link{RFoptions}} if you like to have more internal information in case of failure of an initialisation of a random field simulation. } \value{ If \code{RFgetModelInfo(model)} is called a list is returned with the following elements: \itemize{ \item \code{trans.inv} : logical. Whether the model is translation invariant (stationary) \item \code{isotropic} : logical. Whether the model is rotation invariant (stationary) \item \code{NAs} : in case of an additive model it gives the number of NAs in each submodel \item \code{minmax} : a data frame containing information on all arguments set to \code{NA}s \itemize{ \item \code{pmin}, \code{pmax} : lower and upper endpoint of the parameter values usually found in practice \item \code{type} : integer; recognized particularities of a parameter; an explanation of the values is given after the table, if printed. \item \code{NAN} : the number of \code{NAN}s found \item \code{min}, \code{max} : mathematically valid lower and upper endpoints of the parameter values \item \code{omin}, \code{omax} : logical. If \code{FALSE} the respective mathematical endpoint is included \item \code{col}, \code{row} : the dimension of the parameter. If the parameter is a scalar then \code{col = row = 1}. If it is a vector then \code{col = 1}. \item \code{bayes} : currently not used (always \code{FALSE}) } } Else a list of internal structure is returned. } \me \seealso{command{\link{RFgetModel}}, \command{\link{RFsimulate}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4, storing=TRUE) RFgetModelInfo() model <- RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) RFgetModelInfo(model) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RFspatialGridDataFrame-class.Rd0000644000176200001440000002230013437301604021224 0ustar liggesusers\name{RFspatialGridDataFrame-class} \docType{class} \alias{RFspatialGridDataFrame-class} \alias{RFspatialGridDataFrame} %% S4 methods \alias{RFspDataFrame2conventional,RFspatialGridDataFrame-method} \alias{RFspDataFrame2dataArray,RFspatialGridDataFrame-method} \alias{show,RFspatialGridDataFrame-method} \alias{coerce,RFspatialGridDataFrame,data.frame-method} \alias{coerce,SpatialGridDataFrame,RFspatialGridDataFrame-method} \alias{coerce,RFspatialGridDataFrame,RFspatialPointsDataFrame-method} \alias{coerce,RFspatialGridDataFrame,RFspatialPointsDataFrame,ANY-method} \alias{GridTopology2gridVectors,GridTopology-method} \alias{GridTopology2gridVectors,matrix-method} %\alias{coordinates,RFspatialGridDataFrame-method} only for %"RFpointsDataFrame" and "RFgridDataFrame" defined \alias{[,RFspatialGridDataFrame-method} \alias{[,RFspatialGridDataFrame,ANY,ANY-method} \alias{[,RFspatialGridDataFrame,ANY,ANY,ANY-method} \alias{[<-,RFspatialGridDataFrame-method} \alias{[<-,RFspatialGridDataFrame,ANY,ANY,ANY-method} \alias{dimensions,RFspatialGridDataFrame-method} %\alias{isGridded,RFspatialGridDataFrame-method} \alias{variance,RFspatialGridDataFrame-method} %% S3 methodsgr \alias{print.RFspatialGridDataFrame} \alias{cbind.RFspatialGridDataFrame} \alias{range.RFspatialGridDataFrame} \alias{hist.RFspatialGridDataFrame} \alias{as.matrix.RFspatialGridDataFrame} \alias{as.array.RFspatialGridDataFrame} \alias{as.vector.RFspatialGridDataFrame} \alias{as.data.frame.RFspatialGridDataFrame} \title{Class "RFspatialGridDataFrame" } \description{ Class for spatial attributes that have spatial or spatio-temporal locations (at least of dimension 2) on a (full) regular grid. Direct extension of class \command{\link[sp:SpatialGridDataFrame-class]{SpatialGridDataFrame} from the \pkg{sp}-package. See \command{\link{sp2RF}} for an explicit transformation.} } \usage{ \S4method{RFspDataFrame2conventional}{RFspatialGridDataFrame}(obj, data.frame=FALSE) } \arguments{ \item{obj}{an \code{RFspatialGridDataFrame} object} \item{data.frame}{logical. If \code{TRUE} a \code{data.frame} is returned. } } \section{Creating Objects}{ Objects can be created by using the functions \code{\link{RFspatialGridDataFrame}} or \code{\link{conventional2RFspDataFrame}} or by calls of the form \code{as(x, "RFspatialGridDataFrame")}, where \code{x} is of class \command{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}}. %Ordered full grids are stored instead or unordered non-NA cells; } \section{Slots}{ \describe{ \item{\code{.RFparams}:}{list of 2; \code{.RFparams$n} is the number of repetitions of the random field contained in the \code{data} slot; \code{.RFparams$vdim} gives the dimension of the values of the random field, equals 1 in most cases} \item{\code{data}:}{object of class \code{\link{data.frame}}; containing attribute data } \item{\code{grid}:}{object of class \command{\link[=GridTopology-class]{GridTopology}}; grid parameters } %\item{\code{grid.index}:}{see \link{SpatialPixels-class}; this slot % is of zero length for this class, as the grid is full } %\item{\code{coords}:}{matrix containing a subset of % \code{grid} } %numeric matrix or data.frame with coordinates % (each row is a % point); in case of SpatialPointsDataFrame an object of class % SpatialPoints-class is also allowed % % see \link{SpatialPoints}; points slot which is % not actually filled with all coordinates (only with min/max) \item{\code{bbox}:}{matrix specifying the bounding box } \item{\code{proj4string}:}{object of class \code{\link[sp:CRS-class]{CRS}}; projection } } } \section{Extends}{ Class \code{"SpatialGridDataFrame"}, directly. Class \code{"SpatialGrid"}, by class \code{"SpatialGridDataFrame"}. Class \code{"Spatial"}, by class \code{"SpatialGrid"}. } \section{Methods}{ \describe{ \item{contour}{\code{signature(obj = "RFspatialGridDataFrame")}: generates \command{\link[graphics]{contour}} plots } \item{plot}{\code{signature(obj = "RFspatialGridDataFrame")}: generates nice \command{image} plots of the random field; if \eqn{space-time-dim2}, a two-dimensional subspace can be selected using the argument \code{MARGIN}; to get different slices in a third direction, the argument \code{MARGIN.slices} can be used; for more details see \code{\link{plot-method}} or type \code{method?plot("RFspatialGridDataFrame")}} \item{persp}{\code{signature(obj = "RFspatialGridDataFrame")}: generates \command{\link[graphics]{persp}} plots } \item{show}{\code{signature(x = "RFspatialGridDataFrame")}: uses the \command{show}-method for class \command{\link[sp]{SpatialGridDataFrame}}.} \item{print}{\code{signature(x = "RFspatialGridDataFrame")}: identical to \command{show}-method} \item{RFspDataFrame2conventional}{\code{signature(obj = "RFspatialGridDataFrame")}: conversion to a list of non-\pkg{sp}-package based objects; the \code{data}-slot is converted to an array of dimension \eqn{[1*(vdim>1) + space-time-dimension + 1*(n>1)]}; the \code{grid}-slot is converted to a 3-row matrix; the grid definition of a possible time-dimension becomes a separate list element} \item{RFspDataFrame2dataArray}{\code{signature(obj = "RFspatialGridDataFrame")}: conversion of the \code{data}-slot to an array of dimension \eqn{[space-time-dimension + 2]}, where the space-time-dimensions run fastest, and \eqn{vdim} and \eqn{n} are the last two dimensions} \item{coordinates}{\code{signature(x = "RFspatialGridDataFrame")}: calculates the coordinates from grid definition} \item{[}{\code{signature(x = "RFspatialGridDataFrame")}: selects columns of \code{data}-slot; returns an object of class \code{\link{RFspatialGridDataFrame}}.} \item{[<-}{\code{signature(x = "RFspatialGridDataFrame")}: replaces columns of \code{data}-slot; returns an object of class \code{\link{RFspatialGridDataFrame}}.} \item{as}{\code{signature(x = "RFspatialGridDataFrame")}: converts into other formats, only implemented for target class \code{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}} } \item{cbind}{\code{signature(...)}: if arguments have identical topology, combine their attribute values} \item{range}{\code{signature(x = "RFspatialGridDataFrame")}: returns the range } \item{hist}{\code{signature(x = "RFspatialGridDataFrame")}: plots histogram } \item{as.matrix}{\code{signature(x = "RFspatialGridDataFrame")}: converts \code{data}-slot to matrix } \item{as.array}{\code{signature(x = "RFspatialGridDataFrame")}: converts \code{data}-slot to array } \item{as.vector}{\code{signature(x = "RFspatialGridDataFrame")}: converts \code{data}-slot to vector } \item{as.data.frame}{\code{signature(x = "RFspatialGridDataFrame")}: converts \code{data}-slot and coordinates to a data.frame} } } \section{Details}{ Note that in the \code{data}-slot, each column is ordered according to the ordering of \code{coordinates(grid)}, the first dimension runs fastest and for all BUT the second dimension, coordinate values are in ascending order. In the second dimension, coordinate values run from high to low. Hence, when converting to conventional formats using \command{RFspDataFrame2conventional} or \command{RFspDataFrame2dataArray}, the data array is re-ordered such that all dimensions are in ascending order. \code{as.matrix} does not perform re-ordering. Methods \command{summary}, % \command{isGridded}, and \command{dimensions} are defined for the \dQuote{parent}-class \command{\link[=RFsp-class]{RFsp}}. } \author{Alexander Malinowski, \martin} \seealso{ \code{\link{RFspatialPointsDataFrame-class}}, which is for point locations that are not on a grid, \code{\link{RFgridDataFrame-class}} which is for one-dimensional locations, \code{\link[=RFsp-class]{RFsp}}, \command{\link{sp2RF}} } \keyword{classes} \keyword{print} \keyword{hplot} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 3 x <- GridTopology(cellcentre.offset=c(0, 0), cellsize=c(1, 0.2), cells.dim=c(10, 30)) f <- RFsimulate(model=RMexp(), x=x, n=n) str(f) str(RFspDataFrame2conventional(f)) str(RFspDataFrame2dataArray(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE str(as(f, "RFspatialPointsDataFrame")) plot(f, nmax=2) steps <- c(10, 1, 10, 10) \dontshow{if(!interactive()){warning("modified "); steps<-c(2,1,2,2)}}%ok x2 <- rbind(c(0, 0, 0, 0), c(1, 0.2, 2, 5), steps) scale <- 10 \dontshow{if(!interactive()){warning("modified ");scale<-0.1}}%ok f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=scale), x=x2, n=n, grid = TRUE) plot(f2, MARGIN=c(3,4), MARGIN.slices=1, n.slices=6, nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=n) f.old <- RFsimulate(model=RMexp(), x=x, n=n, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE \dontshow{FinalizeExample()}} RandomFields/man/RRdistr.Rd0000644000176200001440000000737513437301604015271 0ustar liggesusers\name{RRdistr} \alias{RRdistr} \alias{RM_DISTR} \title{Definition of Distribution Families} \description{ \command{RRdistr} defines a distribution family given by \code{fct}. It is used to introduce \link[=RR]{random parameters} based on distributions defined on R. } \usage{ RRdistr(name, nrow, ncol, %ddistr, pdistr, qdistr, rdistr, envir, ...) } \arguments{ \item{name}{an arbitrary family of distributions. E.g. \code{norm()} for the family \command{dnorm}, \command{pnorm}, \command{qnorm}, \command{rnorm}. See examples below. } \item{nrow, ncol}{The matrix size (or vector if \code{ncol=1}) the family returns. Except for very advanced modelling we always have \code{nrow=ncol=1}, which is the default.} % \item{ddistr, pdistr, qdistr, rdistr}{ % only for very advanced users. Instead of passing the family name of % the distribution, an own family name can be given and all four % functions \code{ddistr}, \code{pdistr}, \code{qdistr}, \code{rdistr} % are given explicitely. % If any of these arguments is passed, % all arguments of the function \command{RRdistr} must be passed. % } \item{envir}{an environment; defaults to \code{\link[base]{new.env}()}. } \item{...}{Second possibility to pass the distribution family is to pass a character string as \code{name} and to give the argument within \code{...}. See examples below. } } \note{ \command{\link{RRdistr}} is the generic model introduced automatically when distribution families in R are used in the model definition. See the examples below. } \details{ \command{\link{RRdistr}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ See \link{Bayesian Modelling} for a less technical introduction to hierarchical modelling. The use of \command{RRdistr} is completely on the risk of the user. There is no way to check whether the expressions of the user are mathematically correct. Further, \command{\link{RRdistr}} may not be used in connection with obsolete commands of RandomFields. } \me \seealso{ \command{\link{RMmodel}}, \link{RR}, \command{\link{RFsimulate}}, \command{\link{RFdistr}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter model <- RMgauss(scale=exp(rate=1)) x <- seq(0,10,0.02) n <- 10 \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced 'n'"); n<-1}} for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## another possibility to define exactly the same model above is ## model <- RMgauss(scale=exp()) ## note that however, the following two definitions lead ## to covariance models with fixed scale parameter: ## model <- RMgauss(scale=exp(1)) # fixed to 2.7181 ## model <- RMgauss(scale=exp(x=1)) # fixed to 2.7181 ## here, just two other examples: ## fst model <- RMmatern(nu=unif(min=0.1, max=2)) # random for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## snd, part 1 ## note that the fist 'exp' refers to the exponential function, ## the second to the exponential distribution. (model1 <- RMgauss(var=exp(3), scale=exp(rate=1))) x <- 1:100/10 plot(z1 <- RFsimulate(model=model, x=x)) ## snd, part 2 ## exactly the same result as in the previous example (model2 <- RMgauss(var=exp(3), scale=RRdistr("exp", rate=1))) plot(z2 <- RFsimulate(model=model, x=x)) all.equal(model1, model2) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMpoissonpoly.Rd0000644000176200001440000000325413573655311016535 0ustar liggesusers\name{RMpolygon} \alias{RMpolygon} \title{RMpolygon} \description{ \command{RMpolygon} refers to the indicator function of a typical Poisson polygon, used for instance in the (mixed) Storm process. } \usage{ RMpolygon(lambda) } \arguments{ \item{lambda}{ intensity of the hyperplane process creating the random shape function. The default value is \code{1}. } } \seealso{ \command{\link{RMball}}, \command{\link{RMspheric}}, \command{\link{RFsimulate}}, \command{\link{RMmodel}}. } \author{ Felix Ballani, \url{https://tu-freiberg.de/fakult1/sto/ballani} \martin } \references{ Poisson polygons / Poisson hyperplane tessellation \itemize{ \item Lantuejoul, C. (2002) \emph{Geostatistical Simulation: Models and Algorithms.} Springer. } Poisson storm process \itemize{ \item Lantuejoul, C., Bacro, J.N., Bel L. (2011) Storm processes and stochastic geometry. \emph{Extremes}, \bold{14}(4), 413-428. } Mixed Poisson storm process \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontshow{\dontrun{ model <- RPcoins(shape=RMpolygon()) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x)) }} \dontshow{FinalizeExample()}}RandomFields/man/Bayesian.Rd0000644000176200001440000000644613437301604015431 0ustar liggesusers\name{Hierarchical Modelling} \alias{Bayesian} \alias{bayesian} \alias{Bayesian Modelling} \alias{Hierarchical} \alias{Hierarchical Modelling} \title{Bayesian Spatial Modelling} \description{ \pkg{RandomFields} provides Bayesian modelling to some extend: (i) simulation of hierarchical models at arbitrary depth; (ii) estimation of the parameters of a hierarchical model of depth 1 by means of maximizing the likelihood. } \details{ A Bayesian approach can be taken for scalar, real valued model parameters, e.g. the shape parameter \code{nu} in the \link{RMmatern} model. A random parameter can be passed through a distribution of an existing family, e.g. (\code{dnorm}, \code{pnorm}, \code{qnorm}, \code{rnorm}) or self-defined. It is passed without the leading letter \code{d}, \code{p}, \code{q}, \code{r}, but as a function call e.g \code{norm()}. This function call may contain arguments that must be named, e.g. \code{norm(mean=3, sd=5)}. Usage: \itemize{ \item \code{exp()} denotes the exponential distribution family with rate 1, \item \code{exp(3)} is just the scalar \eqn{e^3} and \item \code{exp(rate=3)} is the exponential distribution family with rate \eqn{3}. } The family can be passed in three ways: \itemize{ \item implicitly, e.g. \code{RMwhittle(nu=exp())} or \item explicitly through \command{\link{RRdistr}}, e.g. \code{RMwhittle(nu=RRdistr(exp()))}. \item by use of \code{\link[=RR]{RRmodels}} of the package. } The first is more convenient, the second more flexible and slightly safer. } \note{ \itemize{ \item While simulating any depth of hierarchical modelling is possible, estimation is currently restricted to one level of hierarchy. \item The effect of the distribution family varies between the different processes: \itemize{ \item in max-stable fields and \command{\link{RPpoisson}}, a new realization of the prior distribution(s) is drawn for each shape function \item in all other cases: a realization of the prior(s) is only drawn once. This effects, in particular, Gaussian fields with argument \code{n>1}, where all realizations are based on the same realization out of the prior distribution(s). } Note that checking the validity of the arguments is rather limited for such complicated models, in general. } } %\references{Ribeiro} \seealso{ \link{RMmodelsAdvanced}. For hierarchical modelling see \link{RR}. } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RRmodels' for hierarchical models ## the following model defines the argument nu of the Whittle-Matern ## model to be an exponential random variable with rate 5. model <- ~ 1 + RMwhittle(scale=NA, var=NA, nu=exp(rate=5)) + RMnugget(var=NA) \dontshow{if (!interactive()) model <- 1 + RMwhittle(scale=NA, var=NA, nu=exp(rate=5))}%ok data(soil) fit <- RFfit(model, x=soil$x, y=soil$y, data=soil$moisture, modus="careless") print(fit) \dontshow{FinalizeExample()}} \keyword{spatial} % library(RandomFields); help.start(); help("bayesian", help_type = "html") RandomFields/man/RMmatern.Rd0000644000176200001440000001261313437301604015414 0ustar liggesusers\name{RMwhittlematern} \alias{RMwhittle} \alias{RMkbessel} \alias{RMmatern} \alias{RMhandcock} \alias{Sobolev} \alias{whittle-matern} \title{Whittle-Matern Covariance Model} \description{ \command{\link{RMmatern}} is a stationary isotropic covariance model belonging to the Matern family. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points. The Whittle model is given by \deqn{C(r)=W_{\nu}(r)=2^{1- \nu} \Gamma(\nu)^{-1}r^{\nu}K_{\nu}(r)}{C(r)=W_{\nu}(r)=2^{1- \nu} \Gamma(\nu)^{-1}r^{\nu}K_{\nu}(r)} where \eqn{\nu > 0}{\nu > 0} and \eqn{K_\nu}{K_\nu} is the modified Bessel function of second kind. The Matern model is given by \deqn{C(r) = \frac{2^{1-\nu}}{\Gamma(\nu)} (\sqrt{2\nu}r)^\nu K_\nu(\sqrt{2\nu}r)}{C(r) = 2^{1- \nu} \Gamma(\nu)^{-1} (\sqrt{2\nu} r)^\nu K_\nu(\sqrt{2\nu} r)} The Handcock-Wallis parametrisation is given by \deqn{C(r) = \frac{2^{1-\nu}}{\Gamma(\nu)} (2\sqrt{\nu}r)^\nu K_\nu(2 \sqrt{\nu}r)}{C(r) = 2^{1- \nu} \Gamma(\nu)^{-1} (2\sqrt{\nu} r)^\nu K_\nu(2\sqrt{\nu} r)} } \usage{ RMwhittle(nu, notinvnu, var, scale, Aniso, proj) RMmatern(nu, notinvnu, var, scale, Aniso, proj) RMhandcock(nu, notinvnu, var, scale, Aniso, proj) } \arguments{ \item{nu}{a numerical value called \dQuote{smoothness parameter}; should be greater than 0.} \item{notinvnu}{logical. If \code{FALSE} then in the definition of the models \eqn{\nu} is replaced by \eqn{1/\nu}. This parametrization seems to be more natural. Default is, however, \code{TRUE} according with the definitions in literature. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The three models are alternative parametrizations of the same covariance function. The Matern model or the Handcock-Wallis parametrisation should be preferred as they seperate the effects of the scaling parameter and the shape parameter. The Whittle-Matern model is the model of choice if the smoothness of a random field is to be parametrized: the sample paths of a Gaussian random field with this covariance structure are \eqn{m}{m} times differentiable if and only if \eqn{\nu > m}{\nu > m} (see Gelfand et al., 2010, p. 24). Furthermore, the fractal dimension (see also \command{\link{RFfractaldim}}) \emph{D} of the Gaussian sample paths is determined by \eqn{\nu}{\nu}: We have \deqn{D = d + 1 - \nu, \nu \in (0,1)}{D = d + 1 - \nu, 0 < \nu < 1} and \eqn{D = d}{D = d} for \eqn{\nu > 1}{\nu > 1} where \eqn{d}{d} is the dimension of the random field (see Stein, 1999, p. 32). If \eqn{\nu=0.5}{\nu=0.5} the Matern model equals \command{\link{RMexp}}. For \eqn{\nu}{\nu} tending to \eqn{\infty}{\infty} a rescaled Gaussian model \command{\link{RMgauss}} \eqn{C(r) = -r^2} appears as limit of the above Handcock-Wallis parametrisation. For generalizations see section \sQuote{See Also}. } \note{ The Whittle-Matern model is a normal scale mixture. } \value{ The functions return an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Covariance function \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. \item Guttorp, P. and Gneiting, T. (2006) Studies in the history of probability and statistics. XLIX. On the Matern correlation family. \emph{Biometrika} \bold{93}, 989--995. \item Handcock, M. S. and Wallis, J. R. (1994) An approach to statistical spatio-temporal modeling of meteorological fields. \emph{JASA} \bold{89}, 368--378. \item Stein, M. L. (1999) \emph{Interpolation of Spatial Data -- Some Theory for Kriging.} New York: Springer. } Tail correlation function (for \eqn{\nu \in (0,1/2]}{0 < \nu \le 1/2}) \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \me \seealso{ \itemize{ \item \command{\link{RMexp}}, \command{\link{RMgauss}} for special cases of the model (for \eqn{\nu=0.5}{\nu=0.5} and \eqn{\nu=\infty}{\nu=\infty}, respectively) \item \command{\link{RMhyperbolic}} for a univariate generalization \item \command{\link{RMbiwm}} for a multivariate generalization \item \command{\link{RMnonstwm}}, \command{\link{RMstein}} for anisotropic (space-time) generalizations % \item \command{\link{}} for \item \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}} for general use. } } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 1, len=100) model <- RMwhittle(nu=1, Aniso=matrix(nc=2, c(1.5, 3, -3, 4))) plot(model, dim=2, xlim=c(-1,1)) z <- RFsimulate(model=model, x, x) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/obsolete2.Rd0000644000176200001440000001324113437301604015563 0ustar liggesusers\name{Obsolete Functions Version 2} \alias{CondSimu} \alias{Covariance} \alias{CovarianceFct} \alias{CovMatrix} \alias{DeleteRegister} \alias{DeleteAllRegisters} \alias{DoSimulateRF} \alias{EmpiricalVariogram} \alias{fitvario} \alias{fractal.dim} \alias{GaussRF} \alias{hurst} \alias{InitSimulateRF} \alias{InitGaussRF} \alias{InitMaxStableRF} \alias{Kriging} \alias{MaxStableRF} \title{Obsolete functions Version 2} \alias{RFparameters} \alias{Variogram} \description{ This part gives the obsolete functions of RandomFields Version 2 that are \bold{not maintained} anymore. } \usage{ Covariance(x, y = NULL, model, param = NULL, dim = NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovarianceFct(x, y = NULL, model, param = NULL, dim =NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovMatrix(x, y = NULL, model, param = NULL, dim = NULL, Distances) DeleteAllRegisters() DeleteRegister(nr=0) DoSimulateRF(n = 1, register = 0, paired=FALSE, trend=NULL) InitSimulateRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend, method = NULL, register = 0, gridtriple, distribution=NA) InitGaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, register = 0, gridtriple) GaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, n = 1, register = 0, gridtriple, paired=FALSE, PrintLevel=1, Storing=TRUE, ...) Variogram(x, model, param = NULL, dim = NULL, Distances) InitMaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, register = 0, gridtriple = FALSE) MaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, n = 1, register = 0, gridtriple = FALSE, ...) EmpiricalVariogram(x, y = NULL, z = NULL, T=NULL, data, grid=NULL, bin, gridtriple = FALSE, phi, theta, deltaT) Kriging(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, given, data, trend=NULL,pch=".", return.variance=FALSE, allowdistanceZero = FALSE, cholesky=FALSE) CondSimu(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, method=NULL, given, data, trend=NULL, n=1, register=0, err.model=NULL, err.param=NULL, err.method=NULL, err.register=1, tol=1E-5, pch=".", paired=FALSE, na.rm=FALSE) RFparameters(...) hurst(x, y = NULL, z = NULL, data, gridtriple = FALSE, sort=TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dim[1] / 5)), log(dim[1]), len=min(100, dim[1]))))), fft.m = c(1, min(1000, (fft.len - 1) / 10)), fft.max.length = Inf, method=c("dfa", "fft", "var"), mode=c("plot", "interactive"),%ok pch=16, cex=0.2, cex.main=0.85, PrintLevel=RFoptions()$basic$printlevel,height=3.5, ...) fractal.dim(x, y = NULL, z = NULL, data, grid=TRUE, gridtriple = FALSE, bin, vario.n=5, sort=TRUE, fft.m = c(65, 86), fft.max.length=Inf, fft.max.regr=150000, fft.shift = 50, method=c("variogram", "fft"), mode=c("plot", "interactive"), pch=16, cex=0.2, cex.main=0.85,%ok PrintLevel = RFoptions()$basic$printlevel, height=3.5, ...) fitvario(x, y=NULL, z=NULL, T=NULL, data, model, param, lower=NULL, upper=NULL, sill=NA, grid=!missing(gridtriple), gridtriple=FALSE, ...) } \arguments{ \item{x, y, model, param, dim, Distances, fctcall, n, register, paired, trend, z, T, grid, method, gridtriple, distribution, PrintLevel, Storing, ..., maxstable, data, bin, phi, theta, deltaT, krige.method, pch, return.variance, allowdistanceZero, cholesky, given, err.model, err.param, err.method, err.register, tol, na.rm, sort, block.sequ, fft.m, fft.max.length, mode, cex, cex.main, height, vario.n, fft.max.regr, fft.shift, lower, upper, sill, nr}{ As the functions are obsolete, all these arguments are not documented anymore. } } \value{ See \sQuote{\href{../doc/version.pdf}{version2}} for details on these obsolete commands. } \seealso{ The functions that should be used instead are, for instance, \command{\link{RFcov}}, \command{\link{RFcovmatrix}}, \command{\link{RFvariogram}}, \command{\link{RFsimulate}}, \command{\link{RFinterpolate}}, \command{\link{RFvariogram}}, \command{\link{RFfit}}, \command{\link{RFoptions}}, \command{\link{RFhurst}}, \command{\link{RFfractaldim}} See \sQuote{\href{../doc/version.pdf}{version2}} for details on the obsolete commands. } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again %\dontshow{RFoptions(internal.warn_newstyle=FALSE, %internal.warn_oldstyle=FALSE)} ## no examples given, as command is obsolete \dontshow{\dontrun{ # ok x <- seq(0, 5, 0.05) model <- "exp" param <- c(0, 1, 0, 1) plot(x, Covariance(x, model=model, param=param)) plot(x, Variogram(x, model=model, param=param)) z <- GaussRF(x, model=model, param=param) plot(x, z, type="l") z <- GaussRF(x=x, y=x, model=model, param=param, grid=TRUE) image(x, x, z) EmpiricalVariogram(x, x, data=z) g1 <- runif(5) * 2 g2 <- runif(5) * 2 z <- GaussRF(g1, g2, grid=FALSE, model=model, param=param) k <- Kriging("S", x, x, given=cbind(g1, g2), data=z, model=model, param=param) Print(range(z), range(k)) col <- rainbow(20) zlim <- range(z, k) image(x, x, k, col=col, zlim=zlim) points(g1, g2, pch=20,cex=2) points(g1, g2, pch=16, col=col[pmax(1, (z-zlim[1]) / diff(zlim) * 20 )]) #% farben stimmen in etwa. estparam <- rep(NA, 4) v <- fitvario(x=g1, y=g2, grid=FALSE, model=model, param=estparam, data=z) Print(v$ml, v$ml$ml.value) }} \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RFdistr.Rd0000644000176200001440000000425313437301604015245 0ustar liggesusers\name{RFdistr} \alias{RFdistr} \alias{RFddistr} \alias{RFpdistr} \alias{RFqdistr} \alias{RFrdistr} \title{ Evaluating distribution families } \description{ Through \command{\link{RRdistr}} distribution families can be passed to \pkg{RandomFields} to create distributions available in the \command{\link{RMmodel}} definitions. } \usage{ RFddistr(model, x, params, dim=1, ...) RFpdistr(model, q, params, dim=1, ...) RFqdistr(model, p, params, dim=1, ...) RFrdistr(model, n, params, dim=1, ...) RFdistr(model, x, q, p, n, params, dim=1, ...) } \arguments{ \item{model,params}{an \code{\link{RRmodel}}.} \item{x}{the location where the density is evaluated} \item{q}{the location where the probability function is evaluated} \item{p}{the value where the quantile function is evaluated} \item{n}{the number of random values to be drawn} \item{dim}{the dimension of the vector to be drawn} \item{\dots}{for advanced use: further options and control arguments for the simulation that are passed to and processed by \command{\link{RFoptions}}} } \details{ \command{RFdistr} is the generic function for the 4 functions belonging to a distribution. } \value{ as described in the arguments } \me \seealso{ \command{\link{RRgauss}}, \link{RR} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a very toy example to understand the use model <- RRdistr(norm()) v <- 0.5 Print(RFdistr(model=model, x=v), dnorm(x=v)) Print(RFdistr(model=model, q=v), pnorm(q=v)) Print(RFdistr(model=model, p=v), qnorm(p=v)) n <- 10 r <- RFdistr(model=model, n=n, seed=0) set.seed(0); Print(r, rnorm(n=n)) ## note that a conditional covariance function given the ## random parameters is given here: model <- RMgauss(scale=exp()) for (i in 1:3) { RFoptions(seed = i + 10) readline(paste("Model no.", i, ": press return", sep="")) plot(model) readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=seq(0,10,0.1))) } \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMprod.Rd0000644000176200001440000000375713437301604015103 0ustar liggesusers\name{RMprod} \alias{RMprod} \title{Plain scalar product} \description{ \command{\link{RMprod}} is a non-stationary covariance model given by \deqn{C(x,y) = \langle \phi(x), \phi(y)\rangle }{C(x,y) = \langle \phi(x), \phi(y)\rangle.} } \usage{ RMprod(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{any function of class \code{\link[=RMmodel-class]{RMmodel}} } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } %\details{} \value{ \command{\link{RMprod}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ In general, this model defines a positive definite kernel and hence a covariance model for all functions \eqn{\phi} with values in an arbitrary Hilbert space. However, as already mentioned above, \eqn{\phi} should stem from a covariance or variogram model, here. } \note{ Do not mix up this model with \command{\link{RMmult}}. See also \command{RMS} for a simple, alternative method to set an arbitrary, i.e. location dependent, univariate variance. } \references{ Wendland, H. \emph{Scattered Data Approximation} (2005) Cambridge: Cambridge University Press. } \me \seealso{ \command{\link{RMid}}, \command{\link{RMid}}, \command{\link{RMsum}}, \command{\link{RMmodel}}, \command{\link{RMmult}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x|| + ||y||) RFcov(RMprod(RMexp()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x / 10|| + ||y / 10 ||) model <- RMprod(RMexp(scale=10)) x <- seq(0,10,len=100) z <- RFsimulate(model=model, x=x, y=x) plot(z) \dontshow{FinalizeExample()}}RandomFields/man/Changings.Rd0000644000176200001440000000454213437301604015572 0ustar liggesusers\name{Changings} \alias{Changings} \alias{changings} \alias{tbmdim} \alias{coord_units} \alias{new_coord_units} \alias{variab_units} \title{Documentation of some further changings} \description{ \itemize{ \item{Version 3.3} \itemize{ \item\code{RFempiricalvariogram}, \code{RFempiricalcovariance} and \code{RFempiricalmadogram} became obsolete. Use \command{\link{RFvariogram}}, \command{\link{RFcov}}, \command{\link{RFmadogram}} instead. \item \code{RFoptions(grDefault=FALSE)} returns to the old style of graphical device handling. Otherwise there is no handling. \item C code is started to be parallelized. \item Some new \link{Multivariate RMmodels} \item New way of passing models, see \link{RFformula}, which allows connections (formulae) between parameters, e.g. one parameter value might be twice as large as another parameter value. Also dummy variables can be \command{\link{RMdeclare}}d. } \item{Options getting obsolete (Version 3 and older)} \itemize{ \item\code{oldstyle} is becoming \code{warn_oldstyle} \item\code{newstyle} is becoming \code{warn_newstyle} \item\code{newAniso} is becoming \code{warn_newAniso} \item\code{ambiguous} is becoming \code{warn_ambiguous} \item\code{normal_mode} is becoming \code{warn_normal_mode} \item\code{colour_palette} is becoming \code{warn_colour_palette} } \item \bold{Changings in option names} \itemize{ \item several changes in \code{RFoptions()$graphics} in version 3.1.11 \item\code{pdfnumber} became in version 3.0.42 \code{filenumber} \item\code{pdfonefile} became in version 3.0.42 \code{onefile} \item\code{pdffile} became in version 3.0.42 \code{file} \item\code{tbmdim} became in version 3.0.41 \code{reduceddim} \item\code{coord_units} became in version 3.0.39 \code{coordunits} \item\code{new_coord_units} became in version 3.0.39 \code{new_coordunits} \item\code{variab_units} became in version 3.0.39 \code{varunits} } } } \seealso{ \link{MajorRevisions}, \link{RandomFields}. } \me \examples{\dontshow{StartExample()} ## no examples given \dontshow{FinalizeExample()}} RandomFields/man/RMepscauchy.Rd0000644000176200001440000000631013437301604016107 0ustar liggesusers\name{RMepscauchy} \alias{RMepscauchy} \title{Generalized Cauchy Family Covariance Model} \description{ \command{\link{RMepscauchy}} is a stationary isotropic covariance model belonging to the generalized Cauchy family. \bold{In contrast to most other models it is not a correlation function.} The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (\varepsilon + r^\alpha)^(-\beta/\alpha)}{C(r) = (\epsilon + r^\alpha)^(-\beta/\alpha)} where \eqn{\epsilon > 0}, \eqn{\alpha \in (0,2]}{0 < \alpha \le 2} and \eqn{\beta > 0}{\beta > 0}. See also \command{\link{RMcauchy}}. } \usage{ RMepscauchy(alpha, beta, eps, var, scale, Aniso, proj) } \arguments{ \item{alpha}{a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension.} \item{beta}{a numerical value; should be positive to provide a valid covariance function for a random field of any dimension.} \item{eps}{a positive value} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model has a smoothness parameter \eqn{\alpha}{\alpha} and a parameter \eqn{\beta}{\beta} which determines the asymptotic power law. More precisely, this model admits simulating random fields where fractal dimension \emph{D} of the Gaussian sample and Hurst coefficient \emph{H} can be chosen independently (compare also \command{\link{RMlgd}}): Here, we have \deqn{ D = d + 1 - \alpha/2, \alpha \in (0,2]}{ D = d + 1 - \alpha/2, 0 < \alpha \le 2} and \deqn{ H = 1 - \beta/2, \beta > 0.}{ H = 1 - \beta/2, \beta > 0.} I. e. the smaller \eqn{\beta}{\beta}, the longer the long-range dependence. The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly. Each covariance function of the Cauchy family is a normal scale mixture. Note that the Cauchy Family (see \command{\link{RMcauchy}}) is included in this family for the choice \eqn{\alpha = 2}{\alpha = 2} and \eqn{\beta = 2 \gamma}{\beta = 2 \gamma}. } \value{ \command{\link{RMepscauchy}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ % \item Gneiting, T. (2002) Compactly supported correlation % functions. \emph{J. Multivariate Anal.} \bold{83} 493--508. \item Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. \emph{SIAM review} \bold{46}, 269--282. } } \me \seealso{ \command{\link{RMcauchy}}, \command{\link{RMcauchytbm}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMepscauchy(alpha=1.5, beta=1.5, scale=0.3, eps=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/weather.Rd0000644000176200001440000000431613437301604015327 0ustar liggesusers\name{weather} \docType{data} \alias{weather} \alias{GKS11} \title{Pressure and temperature forecast errors over the Pacific Northwest} \usage{data(weather)} \description{ Meteorological dataset, which consists of differences between forecasts and observations (forecasts minus observations) of temperature and pressure at 157 locations in the North American Pacific Northwest. } \format{ The data frame \code{weather} contains the following columns: \describe{ \item{pressure}{in units of Pascal} \item{temperature}{in units of degree Celcius} \item{lon}{longitudinal coordinates of the locations} \item{lat}{latitude coordinates of the locations} } Furthermore, some results obtained from the data analysis in \code{\link{jss14}} are delivered that are \code{pars.model}, \code{pars}, \code{whole.model}, \code{whole}. Finally, the variable \code{information} contains packing information (the date and the version of \pkg{RandomFields}). } \details{ The forecasts are from the GFS member of the University of Washington regional numerical weather prediction ensemble (UWME; Grimit and Mass 2002; Eckel and Mass 2005); they were valid on December 18, 2003 at 4 pm local time, at a forecast horizon of 48 hours. } \source{ The data were obtained from Cliff Mass and Jeff Baars from the University of Washington Department of Atmospheric Sciences. } \references{ \itemize{ \item Eckel, A. F. and Mass, C. F. (2005) Aspects of effective mesoscale, short-range ensemble forecasting \emph{Wea. Forecasting} \bold{20}, 328-350. \item Gneiting, T., Kleiber, W. and Schlather, M. (2010) Matern cross-covariance functions for multivariate random fields \emph{J. Amer. Statist. Assoc.} \bold{105}, 1167-1177. \item Grimit, E. P. and Mass, C. F. (2002) Initial results of a mesoscale short-range forecasting system over the Pacific Northwest \emph{Wea. Forecasting} \bold{17}, 192-205. } } \seealso{ A reanalysis has been performed in Section 5 of the \link{jss14} paper. } \me \examples{\dontshow{StartExample()} ## See 'jss14'. \dontshow{FinalizeExample()}} \keyword{datasets} RandomFields/man/RMblend.Rd0000644000176200001440000000430313437301604015207 0ustar liggesusers\name{RMblend} \alias{RMblend} \title{Scale model for a few areas of different scales and/or differentiabilities} \description{ Let \eqn{Z=(Z_1, \ldots Z_k)} be an \eqn{k}-variate random field and \eqn{A_1,\ldots, A_k} a partition of the space. Then \deqn{Y(x) = \sum_{i=1}^k Z_i * 1(x \in A_i)} i.e. the model blends the components of \eqn{Z} to a new, univariate model \eqn{Y}. } \usage{ RMblend(multi, blend, thresholds, var, scale, Aniso, proj) } \arguments{ \item{multi}{a multivariate covariance function} \item{blend,thresholds}{The \code{threshold} is a vector of increasing values. If the value of \code{blend} is below all thresholds up to the \eqn{k}-th threshold, then the \eqn{k}-th component of the field given by \code{multi} is taken. If necessary the components are recycled. Default: \code{threshold = 0.5}, useful for blending a bivariate field if \code{blend} takes only the values \eqn{0} and {1}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMblend}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation. \item Genton, Apanovich Biometrika. } } \me \seealso{ \command{\link{RMSadvanced}}, \command{\link{RMbubble}}, \command{\link{RMscale}}, } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) len <- length(x) m <- matrix(1:len, nc=len, nr=len) m <- m > t(m) image(m) # two areas separated by the first bisector biwm <- RMbiwm(nudiag=c(0.3, 1), nured=1, rhored=1, cdiag=c(1, 1), s=c(1, 1, 0.5)) model <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(m), raw=TRUE)) plot(z <- RFsimulate(model, x, x)) ## takes a while ... \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMdagum.Rd0000644000176200001440000000371113437301604015222 0ustar liggesusers\name{RMdagum} \alias{RMdagum} \title{Dagum Covariance Model Family} \description{ \command{\link{RMdagum}} is a stationary isotropic covariance model. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = 1-(1+r^{-\beta})^{\frac{-\gamma}{\beta}}.}{C(r) = 1-(1+r^(-\beta))^(-\gamma / \beta).} The parameters \eqn{\beta}{\beta} and \eqn{\gamma}{\gamma} can be varied in the intervals \eqn{(0,1]}{(0,1]} and \eqn{(0,1)}{(0,1)}, respectively. } \usage{ RMdagum(beta, gamma, var, scale, Aniso, proj) } \arguments{ \item{beta}{numeric in \eqn{(0,1]}{(0,1]}} \item{gamma}{numeric in \eqn{(0,1)}{(0,1)}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{Like the generalized Cauchy model the Dagum family can be used to model fractal dimension and Hurst effect. For a comparison of these see Berg, C. and Mateau, J. and Porcu, E. (2008). This paper also establishes valid parameter choices for the Dagum family, but be careful because therein the model is parameterized differently. } \value{ \command{\link{RMdagum}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Berg, C. and Mateau, J. and Porcu, E. (2008) The dagum family of isotropic correlation functions. \emph{Bernoulli} \bold{14}(4), 1134--1149. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdagum(beta=0.5, gamma=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RF.Rd0000644000176200001440000001155113437301604014176 0ustar liggesusers\name{RFfunction} \alias{RF} \alias{RFmodel} \alias{RFmodels} \alias{RFfunction} \alias{RFfunctions} \title{Evaluation operators (RF commands)} \description{ Here, all the \command{RF_name_} commands are listed. } \section{Functionals of \code{\link{RMmodels}}}{ The user's \code{\link{RMmodel}} is supplemented internally by operators that are tacitely assumed, e.g. \command{\link{RPgauss}}. Further completions of the user's model determine what should be done with the model, e.g. calculation of the covariance (\command{\link{RFcov}}). The following list gives those \code{RFfunctions} that have an internal representation as completion to the user's model. \tabular{ll}{ % \bold{User's function} \tab \bold{Internal task} \cr \command{\link{RFcalc}} \tab performs some simple calculations based on \command{\link{R.models}} \cr \command{\link{RFcov}} \tab assigns to a covariance model the covariance values at given locations \cr \command{\link{RFcovmatrix}} \tab assigns to a covariance model the matrix of covariance values at given locations \cr % \command{\link{RFget}} \tab not implemented yet\cr \command{\link{RFdistr}} \tab generic function assigning to a distribution family various values of the distribution % (density function, distribution function, quantile, random sample) \cr \command{\link{RFfctn}} \tab assigns to a model the value of the function at given locations. In case of a covariance model \command{\link{RFfctn}} is identical to \command{\link{RFcov}}. \cr \command{\link{RFlikelihood}} \tab assigns to a model and a dataset the (log)likelihood value. \cr \command{\link{RFlinearpart}} \tab assigns to a model and a set of coordinates the linear part of the model, i.e. the deterministic trend and the design matrix. \cr \command{\link{RFpseudovariogram}} \tab assigns to a model the values of the pseudo variogram at given locations\cr \command{\link{RFsimulate}} \tab assigns to a model a realisation of the corresponding random field \cr \command{\link{RFvariogram}} \tab assigns to a model the values of the (cross-)variogram at given locations\cr } } \section{Estimation and Inference}{ \tabular{ll}{ % \bold{User's function} \tab \bold{Description} \cr \command{\link{RFcrossvalidate}} \tab cross validation for Gaussian fields \cr \command{\link{RFvariogram}} \tab empirical variogram \cr \command{\link{RFfit}} \tab (maximum likelihood) fitting of the parameters \cr \command{\link{RFinterpolate}} \tab \code{'kriging' and 'imputing'} \cr % \command{\link{RFlikelihood}} \tab not coded yet % to do \cr \command{\link{RFratiotest}} \tab likelihood ratio test for Gaussian fields \cr } } \section{Graphics for Gaussian fields}{ \tabular{ll}{ \command{\link{RFgui}} \tab educational tool for\cr \tab * manual selection of a covariance model\cr \tab * manual fitting to the empirical variogram \cr \command{\link{RFfractaldim}} \tab determination of the fractal dimension \cr \command{\link{RFhurst}} \tab determination of the Hurst effect (long range dependence) \cr } } \section{Coordinate transformations}{ \tabular{ll}{ \command{\link{RFearth2cartesian}} \tab transformation of earth coordinates to cartesian coordinates \cr \command{\link{RFearth2dist}} \tab transformation of earth coordinates to Euclidean distances } } \section{Information from and to RandomFields}{ \tabular{ll}{ \command{\link{RFgetMethodNames}} \tab currently implemented list of simulation methods \cr \command{\link{RFgetModel}} \tab returns the model used in a \code{\link{RFfunction}}, with some more details %on the implementation % \cr\tab including the default values of the arguments of the model \cr \command{\link{RFgetModelInfo}} \tab similar to \command{\link{RFgetModel}}, but with detailed information on the implementation \cr \command{\link{RFgetModelNames}} \tab lists the implemented models \cr \command{\link{RFoptions}} \tab options of package RandomFields } } \seealso{ \link{RC}, \link{RM}, \link{RP}, \link{RR}, \link{R.}, \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}} } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- RFsimulate(model=RMexp(), 1:10) RFgetModel(RFsimulate, show.call = TRUE) # user's definition RFgetModel(RFsimulate, show.call = FALSE) # main internal part \dontshow{FinalizeExample()}} RandomFields/man/RMgauss.Rd0000644000176200001440000000470513437301604015253 0ustar liggesusers\name{RMgauss} \alias{RMgauss} \title{Gaussian Covariance Model} \description{ \command{\link{RMgauss}} is a stationary isotropic covariance model. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = e^{-r^2}}{C(r)=e^{-r^2}.} } \usage{ RMgauss(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model is called Gaussian because of the functional similarity of the spectral density of a process with that covariance function to the Gaussian probability density function. The Gaussian model has an infinitely differentiable covariance function. This smoothness is artificial. Furthermore, this often leads to singular matrices and therefore numerically instable procedures (cf. Stein, M. L. (1999), p. 29). % See \command{\link{RMgneiting}} for an alternative model that does not % have the disadvantages of the Gaussian model. The Gaussian model is included in the symmetric stable class (see \command{\link{RMstable}}) for the choice \eqn{\alpha = 2}{alpha = 2}. } \value{ \command{\link{RMgauss}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ The use of \command{RMgauss} is questionable from both a theoretical (analytical paths) and a practical point of view (e.g. speed of algorithms). Instead, \command{\link{RMgneiting}} should be used. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \me \seealso{ \command{\link{RMstable}} and \command{\link{RMmatern}} for generalizations; \cr \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. Do not mix up with \command{\link{RPgauss}} or \command{\link{RRgauss}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(scale=0.4) x <- seq(0, 10, 0.02) plot(model) lines(RMgauss(), col="red") plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}} RandomFields/man/RMkolmogorov.Rd0000644000176200001440000000273313437301604016326 0ustar liggesusers\name{RMkolmogorov} \alias{RMkolmogorov} \title{Identical Model} \description{ \command{RMkolmogorov} corresponds to a vector-valued random field with covariance function \deqn{ \gamma_{ij}(h) = \|h\|^{2/3}\left(\frac43 \delta_{ij} - \frac13\frac{h_ih_j}{\|h\|^2}\right)}{ \gamma_{ij}(h) = |h|^{2/3}(4/3 * \delta_{ij} - 1/3 * h_i h_j / \|h\|^2) } } \usage{ RMkolmogorov(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMkolmogorov}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ The above formula is from eq. (6.32) of section 6.2 in Pope, S.B. (2000) \emph{Turbulent Flows.} \bold{Cambridge:} Cambridge University Pess. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMcurlfree}}, \command{\link{RMdivfree}}, \command{\link{RMvector}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-2, 2, len=20) model <- RMkolmogorov() plot(model, dim=3, MARGIN=1:2, fixed.MARGIN=1) simu <- RFsimulate(model, x, y, z=0) plot(simu, select.variables=list(c(1,2)), col=c("red")) \dontshow{FinalizeExample()}} RandomFields/man/RFspatialPointsDataFrame-class.Rd0000644000176200001440000001731513437301604021625 0ustar liggesusers\name{RFspatialPointsDataFrame-class} \docType{class} \alias{RFspatialPointsDataFrame-class} \alias{RFspatialPointsDataFrame} %% S4 methods \alias{RFspDataFrame2conventional,RFspatialPointsDataFrame-method} \alias{show,RFspatialPointsDataFrame-method} \alias{coerce,RFspatialPointsDataFrame,RFspatialGridDataFrame-method} \alias{coerce,RFspatialPointsDataFrame,RFspatialGridDataFrame,ANY-method} \alias{coerce,RFspatialPointsDataFrame,data.frame-method} \alias{coerce,SpatialPointsDataFrame,RFspatialPointsDataFrame-method} \alias{coerce,SpatialPointsDataFrame,RFspatialPointsDataFrame-method} \alias{[,RFspatialPointsDataFrame-method} \alias{[,RFspatialPointsDataFrame,ANY,ANY-method} \alias{[,RFspatialPointsDataFrame,ANY,ANY,ANY-method} \alias{[<-,RFspatialPointsDataFrame-method} \alias{[<-,RFspatialPointsDataFrame,ANY,ANY,ANY-method} \alias{dimensions,RFspatialPointsDataFrame-method} %\alias{isGridded,RFspatialPointsDataFrame-method} \alias{variance,RFspatialPointsDataFrame-method} %% S3 methods \alias{print.RFspatialPointsDataFrame} \alias{cbind.RFspatialPointsDataFrame} \alias{range.RFspatialPointsDataFrame} \alias{hist.RFspatialPointsDataFrame} \alias{as.matrix.RFspatialPointsDataFrame} \alias{as.array.RFspatialPointsDataFrame} \alias{as.vector.RFspatialPointsDataFrame} \alias{as.data.frame.RFspatialPointsDataFrame} \title{Class "RFspatialPointsDataFrame" } \description{ Class for spatial attributes that have spatial or spatio-temporal locations (at least of dimension 2) that are not on a grid. Direct extension of class \code{\link[sp:SpatialPointsDataFrame-class]{SpatialPointsDataFrame}} from the \pkg{sp}-package. See \command{\link{sp2RF}} for an explicit transformation.} \usage{ \S4method{RFspDataFrame2conventional}{RFspatialPointsDataFrame}(obj) } \arguments{ \item{obj}{an \code{RFspatialPointsDataFrame} object} } \section{Creating Objects}{ Objects can be created by using the functions \code{\link{RFspatialPointsDataFrame}} or \code{\link{conventional2RFspDataFrame}} or by calls of the form \code{as(x, "RFspatialPointsDataFrame")}, where \code{x} is of class \command{\link[=RFspatialPointsDataFrame-class]{RFspatialPointsDataFrame}}. %Ordered full grids are stored instead or unordered non-NA cells; } \section{Slots}{ \describe{ \item{\code{.RFparams}:}{list of 2; \code{.RFparams$n} is the number of repetitions of the random field contained in the \code{data} slot, \code{.RFparams$vdim} gives the dimension of the values of the random field, equals 1 in most cases} \item{\code{data}:}{object of class \code{\link[methods:data.frame-class]{data.frame}}, containing attribute data } \item{\code{coords.nrs}:}{See \code{\link{SpatialPointsDataFrame}}. } \item{\code{coords}:}{matrix of coordinates (each row is a point); in case of SpatialPointsDataFrame an object of class \code{\link[=SpatialPoints-class]{SpatialPoints}} is also allowed, see \link{SpatialPoints}.} \item{\code{bbox}:}{matrix specifying the bounding box } \item{\code{proj4string}:}{object of class \code{\link[sp:CRS-class]{CRS}; projection }} } } \section{Extends}{ Class \code{\link[=SpatialPointsDataFrame-class]{SpatialPointsDataFrame}}, directly. Class \code{\link[=SpatialPoints-class]{SpatialPoints}}, by class \code{\link[=SpatialPointsDataFrame]{SpatialPointsDataFrame}}. Class \code{\link[=Spatial-class]{Spatial}}, by class \code{\link[=SpatialPoints]{SpatialPoints}}. } \section{Methods}{ \describe{ \item{plot}{\code{signature(obj = "RFspatialPointsDataFrame")}: generates nice plots of the random field; if \eqn{space-time-dim2}, a two-dimensional subspace can be selected using the argument \code{MARGIN}; to get different slices in a third direction, the argument \code{MARGIN.slices} can be used; for more details see \code{\link{plot-method}} or type \code{method?plot("RFspatialPointsDataFrame")}} \item{show}{\code{signature(x = "RFspatialPointsDataFrame")}: uses the \command{show}-method for class \command{\link[sp]{SpatialPointsDataFrame}}} \item{print}{\code{signature(x = "RFspatialPointsDataFrame")}: identical to \command{show}-method} \item{RFspDataFrame2conventional}{\code{signature(obj = "RFspatialPointsDataFrame")}: conversion to a list of non-\pkg{sp}-package based objects; the \code{data}-slot is converted to an array of dimension \eqn{[1*(vdim>1) + space-time-dimension + 1*(n>1)]}} \item{coordinates}{\code{signature(x = "RFspatialPointsDataFrame")}: returns the coordinates} \item{[}{\code{signature(x = "RFspatialPointsDataFrame")}: selects columns of \code{data}-slot; returns an object of class \code{\link{RFspatialPointsDataFrame}}} \item{[<-}{\code{signature(x = "RFspatialPointsDataFrame")}: replaces columns of \code{data}-slot; returns an object of class \code{\link{RFspatialPointsDataFrame}}} \item{as}{\code{signature(x = "RFspatialPointsDataFrame")}: converts into other formats, only implemented for target class \code{\link[=RFspatialGridDataFrame-class]{RFspatialGridDataFrame}} } \item{cbind}{\code{signature(...)}: if arguments have identical topology, combine their attribute values} \item{range}{\code{signature(x = "RFspatialPointsDataFrame")}: returns the range } \item{hist}{\code{signature(x = "RFspatialPointsDataFrame")}: plots histogram } \item{as.matrix}{\code{signature(x = "RFspatialPointsDataFrame")}: converts \code{data}-slot to matrix } \item{as.array}{\code{signature(x = "RFspatialPointsDataFrame")}: converts \code{data}-slot to array } \item{as.vector}{\code{signature(x = "RFspatialPointsDataFrame")}: converts \code{data}-slot to vector } \item{as.data.frame}{\code{signature(x = "RFspatialPointsDataFrame")}: converts \code{data}-slot and coordinates to a data.frame} } } \section{Details}{ Note that in the \code{data}-slot, each column is ordered according to the ordering of \code{coordinates(grid)}, the first dimension runs fastest and for all BUT the second dimension, coordinate values are in ascending order. In the second dimension, coordinate values run from high to low. Hence, when converting to conventional formats using \command{RFspDataFrame2conventional} or \command{RFspDataFrame2dataArray}, the data array is re-ordered such that all dimensions are in ascending order. \code{as.matrix} does not perform re-ordering. Methods \command{summary} and \command{dimensions} are defined for the \dQuote{parent}-class \command{\link[=RFsp-class]{RFsp}}. } \author{Alexander Malinowski, \martin} \seealso{ \code{\link{RFspatialGridDataFrame-class}}, which is for point locations that are on a grid, \code{\link{RFpointsDataFrame-class}} which is for one-dimensional locations, \code{\link[=RFsp-class]{RFsp}}, \command{\link{sp2RF}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- cbind(runif(50), runif(50)) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE try(as(f, "RFspatialGridDataFrame")) # yields error plot(f, nmax=2) f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=10), x=cbind(x,x), n=4) plot(f2, MARGIN=c(3,4), nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=3) f.old <- RFsimulate(model=RMexp(), x=x, n=3, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE \dontshow{FinalizeExample()}} \keyword{classes} \keyword{print} \keyword{hplot} RandomFields/man/RFmadogram.Rd0000644000176200001440000000757313437301604015717 0ustar liggesusers\name{RFmadogram} \alias{RFmadogram} \title{Empirical (Cross-)Madogram} \description{ Calculates the empirical (cross-)madogram. The empirical (cross-)madogram of two random fields \eqn{X}{X} and \eqn{Y}{Y} is given by \deqn{\gamma(r):=\frac{1}{N(r)} \sum_{(t_{i},t_{j})|t_{i,j}=r} |(X(t_{i})-X(t_{j}))||(Y(t_{i})-Y(t_{j}))|}{\gamma(r):=1/N(r) \sum_{(t_{i},t_{j})|t_{i,j}=r} |(X(t_{i})-X(t_{j}))||(Y(t_{i})-Y(t_{j}))|} where \eqn{t_{i,j}:=t_{i}-t_{j}}{t_{i,j}:=t_{i}-t_{j}}, and where \eqn{N(r)}{N(r)} denotes the number of pairs of data points with distancevector \eqn{t_{i,j}=r}{t_{i,j}=r}. } \usage{ RFmadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} \item{data}{\argData} \item{bin}{\argBin} \item{phi}{\argPhi} \item{theta}{\argTheta} \item{deltaT}{\argDeltaT} \item{vdim}{\argVdim} } \details{ \command{\link{RFmadogram}} computes the empirical cross-madogram for given (multivariate) spatial data. The spatial coordinates \code{x}, \code{y}, \code{z} should be vectors. For random fields of spatial dimension \eqn{d > 3} write all vectors as columns of matrix x. In this case do neither use y, nor z and write the columns in \code{gridtriple} notation. If the data is spatially located on a grid a fast algorithm based on the fast Fourier transformed (fft) will be used. As advanced option the calculation method can also be changed for grid data (see \command{\link{RFoptions}}.) It is also possible to use \command{\link{RFmadogram}} to calculate the pseudomadogram (see \command{\link{RFoptions}}). } \value{ \command{\link{RFmadogram}} returns objects of class \command{\link[=RFempVariog-class]{RFempVariog}}. } \references{ Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. Stein, M. L. (1999) \emph{Interpolation of Spatial Data.} New York: Springer-Verlag } \author{Jonas Auel; Sebastian Engelke; Johannes Martini; \martin} \seealso{ \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFcov}}, \command{\link{RFpseudomadogram}}. \command{\link{RFvariogram}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z, phi=4) plot(emp.vario) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFmadogram(data=z, deltaT=c(10, 1)) plot(emp.vario, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFmadogram(data=dta, phi=4) plot(ev, boundaries=FALSE) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMderiv.Rd0000644000176200001440000000334413437301604015240 0ustar liggesusers\name{RMderiv} \alias{RMderiv} \alias{derivative} \alias{gradient} \title{Gradient of a field} \description{ \command{\link{RMderiv}} is a multivariate covariance model which models a field and its gradient. For an isotropic covariance model \eqn{varphi}, the covariance \eqn{C} given by \command{RMderiv} equals \deqn{C_{11}(x,y) = \varphi(\| x - y\|)} \deqn{C_{j1}(x,y) = -C_{1j}(x,y) = \partial \varphi(\|x - y\|) / \partial x} \deqn{C_{i,j}(x,y) = \partial^2 \varphi(\|x - y\|) / \partial x \partial y} for \eqn{i,j = 2,\ldots, d} where \eqn{d} is the dimension of the field. } \usage{ RMderiv(phi, which, var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary covariance model (in 2 or 3 dimensions).} \item{which}{vector of integers. If not given all components are returned; otherwise the selected components are returned. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMderiv}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Matheron } } \me \seealso{ \command{\link{RMcurlfree}}, \command{\link{RMdivfree}}, \command{\link{RMvector}} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMderiv(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.4) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated) \dontshow{FinalizeExample()}} RandomFields/man/GaussianFields.Rd0000644000176200001440000002045413437301604016572 0ustar liggesusers\name{GaussianFields} \alias{Gaussian} \title{Methods for Gaussian Random Fields} \description{ Here, all the methods (models) for simulating Gaussian random fields are listed. } \section{Implemented models}{ \tabular{ll}{ \command{\link{RPcirculant}} \tab simulation by circulant embedding \cr \command{\link{RPcutoff}} \tab simulation by a variant of circulant embedding \cr \command{\link{RPcoins}} \tab simulation by random coin / shot noise \cr \command{\link{RPdirect}} \tab through the square root of the covariance matrix\cr \command{\link{RPgauss}} \tab generic model that chooses automatically among the specific methods \cr \command{\link{RPhyperplane}} \tab simulation by hyperplane tessellation \cr \command{\link{RPintrinsic}} \tab simulation by a variant of circulant embedding \cr \command{\link{RPnugget}} \tab simulation of (anisotropic) nugget effects \cr \command{\link{RPsequential}} \tab sequential method \cr \command{\link{RPspecific}} \tab model specific methods (very advanced)\cr \command{\link{RPspectral}} \tab spectral method \cr \command{\link{RPtbm}} \tab turning bands \cr } } \section{Computing demand for simulations}{ Assume at \eqn{n} locations in \eqn{d} dimensions a \eqn{v}-variate field has to be simulated. Let \deqn{f(n, d) = 2^d n \log(n)}{f(n, d) = 2^d * n * log(n)} The following table gives in particular the time and memory needed for the specific simulation method. \tabular{lllllll}{ \tab grid \tab \eqn{v} \tab \eqn{d} \tab time \tab memory \tab comments\cr \command{\link{RPcirculant}} \tab yes \tab any \tab \eqn{\le 13}{<=13} \tab\eqn{O(v^3f(n, d))} \tab \eqn{O(v^2f(n, d))}\tab \cr \tab no \tab any \tab \eqn{\le 13}{<=13} \tab \eqn{O(v^3 f(k, d))} \tab \eqn{O(v^2f(k, d))} \tab \eqn{k \sim }{k ~ }\command{\link[=RFoptions]{approx_step}}\eqn{{}^{-d}}{^{-d}}\cr \command{\link{RPcutoff}} \tab \tab \tab \tab \tab \tab see RPcirculant above \cr \command{\link{RPcoins}} \tab yes \tab \eqn{1} \tab \eqn{\le 4}{<=4} \tab \eqn{O(k n)}{O(k * n)} \tab\eqn{ O(n) }\tab \eqn{k \sim}{k ~ }\eqn{(lattice spacing)^{-d}} \cr \tab no \tab \eqn{1} \tab \eqn{\le 4}{<=4} \tab \eqn{O(k n)}{O(k * n)} \tab \eqn{O(n)} \tab \eqn{k} depends on the geometry \cr \command{\link{RPdirect}} \tab any\tab any\tab any \tab\eqn{O(1)..O(v^2 n^2)}{ O(v^2 * n^2)}\tab\eqn{ O(v^2 n^2)}{ O(v^2 * n^2)}\tab effort to investigate the covariance matrix, if \code{\link[=RFoptions]{matrix_methods}} is not specified (default)\cr \tab \tab \tab \tab\eqn{O(v n)}{ O(v * n)}\tab\eqn{ O(v n)}{ O(v * n)}\tab covariance matrix is diagonal \cr \tab \tab \tab \tab see \pkg{\link[spam:SPAM]{spam}} \tab \eqn{O(z + v n)}{O(z + v * n)}\tab covariance matrix is sparse matrix with \eqn{z} non-zeros\cr \tab\tab \tab \tab \eqn{O(v^3 n^3)}{O(v^3 * n^3)}\tab \eqn{O(v^2 n^2)}{O(v^2*n^2)}\tab arbitrary covariance matrix (preparation) \cr \tab\tab \tab \tab \eqn{O(v^2 n^2)}{O(v^2*n^2)}\tab \eqn{O(v^2 n^2)}{O(v^2*n^2)}\tab arbitrary covariance matrix (simulation)\cr \command{\link{RPgauss}} \tab any \tab any \tab any \tab \eqn{O(1) \ldots O(v^3n^3)}{O(1)..O(v^3*n^3)} \tab \eqn{O(1)\ldots O(n^2)}{O(1)..O(n^2)}\tab \bold{only} the selection process; \eqn{O(1)} if first method tried is successful \cr \command{\link{RPhyperplane}} \tab any \tab \eqn{1} \tab \eqn{2} \tab \eqn{O(n / s^d)} \tab \eqn{O(n / s^d)}\tab \eqn{s = }\code{\link[=RMmodels]{scale}}\cr \command{\link{RPintrinsic}} \tab \tab \tab \tab \tab \tab see RPcirculant above\cr \command{\link{RPnugget}} \tab any \tab any\tab any\tab \eqn{O(v n)} \tab \eqn{O(v n)} \tab\cr \command{\link{RPsequential}} \tab any\tab \eqn{1} \tab any \tab \eqn{O(S^3 b^3)}{O(S^3 * b^3)} \tab \eqn{O(S^2 b^2)}{O(S^2*b^2)} \tab \eqn{n=ST}{n = S * T}; \eqn{S} and \eqn{T} the number of spatial and temporal locations, respectively; \eqn{b = }\code{\link[=RPsequential]{back_steps}} (preparation) \cr \tab \tab \tab \tab \eqn{O(n S b^2)}{O(n * S * b^2)} \tab \eqn{O(S^2 b^2) + O(n)}{O(n)} \tab (simulation) \cr \command{\link{RPspectral}} \tab any \tab \eqn{1} \tab \eqn{\le 2}{<=2} \tab\eqn{O(C(d) n)}{O(C(d) * n)} \tab \eqn{ O(n) }\tab \eqn{C(d)} : large constant increasing in \eqn{d} \cr \command{\link{RPtbm}} \tab any \tab \eqn{1} \tab \eqn{\le 4}{<=4} \tab \eqn{ O(C(d) (n + L) }{ O(C(d) * (n + L))} \tab\eqn{ O(n + L)} \tab\eqn{C(d)} : large constant increasing in \eqn{d}; \eqn{L} is the effort needed to simulate on a line (or plane)\cr \command{\link{RPspecific}} \tab \tab \tab \tab \tab \tab \bold{only} the specific part \cr * * \command{\link{RMplus}}\tab any \tab any \tab any \tab O(v n) \tab O(v n) \tab\cr * * \command{\link{RMS}}\tab any \tab any \tab any \tab O(1) \tab O(v n) \tab\cr * * \command{\link{RMmult}}\tab any \tab any \tab any \tab O(v n) \tab O(v n) \tab\cr } } \section{Computing demand for interpolation}{ Assume \eqn{v}-variate data are given at \eqn{n} locations in \eqn{d} dimensions. To interpolate at \eqn{k} locations RandomFields needs \tabular{lllllll}{ grid \tab \eqn{v} \tab \eqn{d} \tab time \tab memory \tab comments\cr any\tab any\tab any \tab \eqn{O(1)..O(v^2 n^2)}{ O(v^2 * n^2)}\tab\eqn{ O(v^2 n^2)}{ O(v^2 * n^2)}\tab effort to investigate the covariance matrix, if \code{\link[=RFoptions]{matrix_methods}} is not specified (default) \cr \tab \tab \tab\eqn{O(v ^2 n k)}{ O(v^2 * n k)}\tab\eqn{ O(v (n + k))}{ O(v * (n + k))}\tab covariance matrix is diagonal \cr \tab \tab \tab see \pkg{\link[spam:SPAM]{spam}}+ O(v^2nk) \tab \eqn{O(z + v (n + k))}{O(z + v * (n + k))}\tab covariance matrix is sparse matrix with \eqn{z} non-zeros\cr \tab \tab \tab \eqn{O(v^3 n^3 + v^2nk)}{O(v^3*n^3 + v^2*n*k)}\tab \eqn{O(v^2 n^2 + v*k)}{O(v^2*n^2 + v*k)}\tab arbitrary covariance matrix } } \section{Computing demand for conditional simulation}{ Assume \eqn{v}-variate data are given at \eqn{n} locations \eqn{x_1,\ldots, x_n}{x_1,...,x_n} in \eqn{d} dimensions. To conditionally simulate at \eqn{k} locations \eqn{y_1,\ldots, y_k}{y_1,...,y_k}, the computing demand equals the sum of the demand for interpolating and the demand for simulating on the \eqn{k+n} locations. (Grid algorithms for simulating will apply if the \eqn{k} locations \eqn{y_1,\ldots, y_k}{y_1,...,y_k} are defined by a grid and the \eqn{n} locations \eqn{x_1,\ldots, x_n}{x_1,...,x_n} are a subset of \eqn{y_1,\ldots, y_k}{y_1,...,y_k}, a situation typical in image analysis.) } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. % \item Gneiting, T. and Schlather, M. (2004) % Statistical modeling with covariance functions. % \emph{In preparation.} \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. % \item Schlather, M. (2002) Models for stationary max-stable % random fields. \emph{Extremes} \bold{5}, 33-44. \item Yaglom, A.M. (1987) \emph{Correlation Theory of Stationary and Related Random Functions I, Basic Results.} New York: Springer. \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3nd edition. } } \seealso{ \link{RP}, \command{\link{Other models}}, \command{\link{RMmodel}}, \command{\link{RFgetMethodNames}}, \command{\link{RFsimulateAdvanced}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again set.seed(1) x <- runif(90, 0, 500) z <- RFsimulate(RMspheric(), x) z <- RFsimulate(RMspheric(), x, max_variab=10000) \dontshow{FinalizeExample()}} RandomFields/man/RMexp.Rd0000644000176200001440000000412313437301604014717 0ustar liggesusers\name{RMexp} \alias{RMexp} \title{Exponential Covariance Model} \description{ \command{\link{RMexp}} is a stationary isotropic covariance model whose corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = e^{-r}.}{C(r) = exp(-r).} } \usage{ RMexp(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model is a special case of the Whittle covariance model (see \command{\link{RMwhittle}}) if \eqn{\nu=\frac{1}{2}}{\nu=0.5} and of the symmetric stable family (see \command{\link{RMstable}}) if \eqn{\nu = 1}{\nu=1}. Moreover, it is the continuous-time analogue of the first order autoregressive time series covariance structure. The exponential covariance function is a normal scale mixture. } \value{ \command{\link{RMexp}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Covariance model \itemize{ \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. } Tail correlation function \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \me \seealso{ \command{\link{RMwhittle}}, \command{\link{RMstable}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMnsst.Rd0000644000176200001440000000443613437301604015121 0ustar liggesusers\name{RMnsst} \alias{RMnsst} \title{Non-Separable Space-Time model} \description{ \command{\link{RMnsst}} is a univariate stationary spaceisotropic covariance model whose corresponding covariance is given by \deqn{C(h,u)= (\psi(u)+1)^{-\delta/2} \phi(h /\sqrt(\psi(u) +1))} } \usage{ RMnsst(phi, psi, delta, var, scale, Aniso, proj) } \arguments{ \item{phi}{is a normal mixture \command{\link{RMmodel}}, cf.\cr \code{RFgetModelNames(monotone="normal mixture")} } \item{psi}{is a variogram \command{\link{RMmodel}}.} \item{delta}{a numerical value; must be greater than or equal to the spatial dimension of the field.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model is used for space-time modelling where the spatial component is isotropic. } \value{ \command{\link{RMnsst}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. (1997) Normal scale mixtures and dual probability densitites, \emph{J. Stat. Comput. Simul.} \bold{59}, 375-384. \item Gneiting, T. (2002) Nonseparable, stationary covariance functions for space-time data, \emph{JASA} \bold{97}, 590-600. \item Gneiting, T. and Schlather, M. (2001) Space-time covariance models. In El-Shaarawi, A.H. and Piegorsch, W.W.: \emph{The Encyclopedia of Environmetrics.} Chichester: Wiley. % \item Zastavnyi, V. and Porcu, E. (2011) % Caracterization theorems for the Gneiting class space-time % covariances. % \emph{Bernoulli}, \bold{??}. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RMgennsst}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnsst(phi=RMgauss(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.25) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x)) \dontshow{FinalizeExample()}} RandomFields/man/RFcovmatrix.Rd0000644000176200001440000000335213437301604016133 0ustar liggesusers\name{RFcovmatrix} \alias{RFcovmatrix} \title{Covariance matrix} \description{ \command{\link{RFcovmatrix}} returns the covariance matrix for a set of points; } \usage{ RFcovmatrix(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} } \details{ \command{RFcovmatrix} returns a covariance matrix. Here, a matrix of coordinates (\code{x}) or a vector or a matrix of \code{distances} is expected. \command{RFcovmatrix} also allows for variogram models. Then the negative of the variogram matrix is returned. } \value{ \command{RFcovmatrix} returns a covariance matrix. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFfctn}}, \command{\link{RFcalc}}, \command{\link{RFcov}}, \command{\link{RFpseudovariogram}}, \command{\link{RFvariogram}}. } \examples{\dontshow{StartExample()} ################################################## # Example: get covariance matrix C(x_i,x_j) # at given locations x_i, i=1,...,n # # here for an isotropic stationary covariance model # yields a 4 times 4 covariance matrix of the form # C(0) C(5) C(3) C(2.5) # C(5) C(0) C(4) C(2.5) # C(3) C(4) C(0) C(2.5) # C(2.5) C(2.5) C(2.5) C(0) model <- RMexp() # the covariance function C(x,y)=C(r) of this model # depends only on the distance r between x and y RFcovmatrix(model=model, distances=c(5,3,2.5,4,2.5,2.5), dim=4) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RR.Rd0000644000176200001440000000630213437301604014210 0ustar liggesusers\name{Distribution Families} \alias{RR} \alias{RRmodel} \alias{RRmodels} \title{ Distribution families (RR commands) } \description{ Distribution families to specify random parameters in the model definition. } \note{ The allowance of random parameters is a very recent, developing feature of \pkg{RandomFields}. Future changings of the behaviour are not unlikely. } \details{ See \link{Bayesian Modelling} for a less technical introduction to hierarchical modelling. When simulating Gaussian random fields, the random parameters are drawn only once at the very beginning. So, if the argument \code{n} in \command{\link{RFsimulate}} is greater than \code{1} then \code{n} simulations conditional on a single realization of the random parameters are performed. See the examples below. There are (simple) multivariate versions and additional versions to the distributions families implemented. Further, \bold{any} distribution family defined in R can be used, see the examples below. These functions will allow for Bayesian modelling. (Future project). } \section{Implemented models}{ \tabular{ll}{ \command{\link{RRdeterm}} \tab no scattering \cr \command{\link{RRdistr}} \tab families of distributions transferred from R \cr \command{\link{RRgauss}} \tab a (multivariate) Gaussian random variable \cr \command{\link{RRloc}} \tab modification of location and scale \cr \command{\link{RRspheric}} \tab random scale for the \command{\link{RMball}} to simulate \command{\link{RMspheric}}, etc. %on lower % dimensions by \command{\link{RPcoins}} and \command{\link{RPpoisson}} \cr \command{\link{RRunif}} \tab a (multivariate) uniform random variable \cr } } \note{ A further random element is \command{\link{RMsign}}, which is an operator on shape functions. As an exception its name starts with \code{RM} and not with \code{RR}. } \me \seealso{ \link{RC}, \link{RF}, \link{RM}, \link{RP}, \command{\link{Other models}}, \command{\link{RFdistr}}, \code{\link[=RMmodelgenerator-class]{RMmodelgenerator}}, \link{R.} } \keyword{spatial} \keyword{distribution} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here, the scale is given by an exponential variable: model <- RMgauss(scale=exp()) for (i in 1:4) { RFoptions(seed = i) # each leads to a simulation with a different scale parameter plot(model) ## random plot(RFsimulate(model, x=seq(0,10,0.1))) readline("press return") } # but here, all 4 simulations have the same (but random) scale: plot(RFsimulate(model, x=seq(0,10,0.1), n=4)) ## hierarchical models are also possible: ## here, the scale is given by an exponential variable whose ## rate is given by a uniform variable model <- RMgauss(scale=exp(rate=unif())) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1))) ## HOWEVER, the next model is deterministic with scale \code{e=2.718282}. model <- RMgauss(scale=exp(1)) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1))) \dontshow{FinalizeExample()}}RandomFields/man/RMgennsst.Rd0000644000176200001440000000344613437301604015613 0ustar liggesusers\name{RMgennsst} \alias{RMgennsst} \title{Non-Separable Space-Time model} \description{ \command{\link{RMgennsst}} is a univariate stationary spaceisotropic covariance model on \eqn{R^d} whose corresponding covariance is given by \deqn{C(h,u)= \phi( sqrt(h^\top \psi^{-1}(u) h)) / \sqrt(det(psi))} } \usage{ RMgennsst(phi, psi, dim_u, var, scale, Aniso, proj) } \arguments{ \item{phi}{is a normal mixture \command{\link{RMmodel}}, cf.\cr \code{RFgetModelNames(monotone="normal mixture")}. } \item{psi}{is a \eqn{d}-variate variogram model \command{\link{RMmodel}}.} \item{dim_u}{the dimension of the component \code{u}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model is used for space-time modelling where the spatial component is isotropic. } \value{ \command{\link{RMgennsst}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ % \item Zastavnyi, V. and Porcu, E. (2011) % Caracterization theorems for the Gneiting class space-time % covariances. % \emph{Bernoulli}, \bold{??}. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. } } \me \seealso{ \command{\link{RMnsst}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} % to do \dontshow{ RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again % RMgennsst( RMwhittle(nu=4, s=3), RMconstant(diag(3))) } \dontshow{FinalizeExample()}} RandomFields/man/RMbrownresnick.Rd0000644000176200001440000000473213437301604016637 0ustar liggesusers\name{RMbrownresnick} \alias{RMbrownresnick} \alias{powered error function} \alias{error function model} \title{Tail correlation function of the Brown-Resnick process} \description{ \command{RMbrownresnick} defines the tail correlation function of the Brown-Resnick process. \deqn{C(h) = 2 - 2\Phi(\sqrt{\gamma(h)} / 2)} where \eqn{\phi} is the standard normal distribution function and \eqn{\gamma} is the \bold{semi-}variogram. } \usage{ RMbrownresnick(phi, var, scale, Aniso, proj) } \arguments{ \item{phi}{variogram of class \code{\link[=RMmodel-class]{RMmodel}}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ object of class \code{\link[=RMmodel-class]{RMmodel}} } \note{ \bold{In the paper Kabluchko et al. (2009) the variogram instead of the semi-variogram is considered, so the formulae differ slightly.} \bold{In Version 3.0.33 a typo has been corrected.} Here, a definition is used that is consistent with the rest of the package. } \details{ For a given \command{\link{RMmodel}} the function \code{\link{RMbrownresnick}(\link{RMmodel}())} 'returns' the tail correlation function of a Brown-Resnick process with variogram \command{\link{RMmodel}}. } \references{ \itemize{ \item Kabluchko, Z., Schlather, M. & de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions \emph{Ann. Probab.} \bold{37}, 2042-2065. \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \seealso{ \command{\link{RFsimulate}}, \command{\link{RMm2r}}, \command{\link{RMm3b}}, \command{\link{RMmps}}, \command{\link{RMmodel}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again #plot covariance model of type RMbrownresnick RMmodel <- RMfbm(alpha=1.5, scale=0.2) plot(RMbrownresnick(RMmodel)) #simulate and plot corresponding Gaussian random field x <- seq(-5, 5, 0.05) z <- RFsimulate(RMbrownresnick(RMmodel), x=x, y=x) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RPtbm.Rd0000644000176200001440000001437413437301604014721 0ustar liggesusers\name{Tbm} \alias{Tbm} \alias{RPtbm} \title{Turning Bands method} \description{ The Turning Bands method is a simulation method for stationary, isotropic (univariate or multivariate) random fields in any dimension and defined on arbitrary points or arbitrary grids. It performs a multidimensional simulation by superposing lower-dimensional fields. In fact, the Turning Bands method is called with the Turning Bands model, see \command{\link{RMtbm}}. \cr For details see \command{\link{RMtbm}}. } \usage{ RPtbm(phi, boxcox, fulldim, reduceddim, layers, lines, linessimufactor, linesimustep, center, points) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance function to be simulated; a univariate stationary isotropic covariance model (see \code{RFgetModelNames(type="positive definite", domain="single variable", isotropy="isotropic", vdim=1)}) which is valid in dimension \code{fulldim}. } \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } % \item{loggauss}{see \command{\link{RPgauss}}.} \item{fulldim}{a positive integer. The dimension of the space of the random field to be simulated.} \item{reduceddim}{a positive integer; less than \code{fulldim}. The dimension of the auxiliary hyperplane (most frequently a line, i.e. \code{reduceddim=1}) used in the simulation. } \item{layers}{a boolean value; for space-time model. If \code{TRUE} then the turning layers are used whenever a time component is given. If \code{NA} the turning layers are used only when the traditional TBM is not applicable. If \code{FALSE} then turning layers may never be used. Default: \code{TRUE}. } \item{lines}{ Number of lines used. Default: \code{60}. } \item{linessimufactor}{ \code{linessimufactor} or \code{linesimustep} must be non-negative; if \code{linesimustep} is positive then \code{linessimufactor} is ignored. If both arguments are naught then \code{points} is used (and must be positive). The grid on the line is \code{linessimufactor}-times finer than the smallest distance. See also \code{linesimustep}. Default: \code{2.0}. } \item{linesimustep}{ If \code{linesimustep} is positive the grid on the line has lag \code{linesimustep}. See also \code{linessimufactor}. Default: \code{0.0}. } \item{center}{Scalar or vector. If not \code{NA}, the \code{center} is used as the center of the turning bands for \code{fulldim}. Otherwise the center is determined automatically such that the line length is minimal. See also \code{points} and the examples below. Default: \code{NA}. } \item{points}{integer. If greater than 0, \code{points} gives the number of points simulated on the TBM line, hence must be greater than the minimal number of points given by the size of the simulated field and the two parameters \code{linessimufactor} and \code{linesimustep}. If \code{points} is not positive the number of points is determined automatically. The use of \code{center} and \code{points} is highlighted in an example below. Default: \code{0}. } } \note{Both the precision and the simulation time depend heavily on \code{linesimustep} and \code{linessimufactor}. For covariance models with larger values of the scale parameter, \code{linessimufactor=2} is too small. } \details{ \itemize{ \item 2-dimensional case\cr It is generally difficult to use the turning bands method (\command{RPtbm}) directly in the 2-dimensional space. Instead, 2-dimensional random fields are frequently obtained by simulating a 3-dimensional random field (using \command{RPtbm}) and taking a 2-dimensional cross-section. See also the arguments \code{fulldim} and \code{reduceddim}. \item 4-dimensional case\cr The turning layers can be used for the simulations with a (formal) time component. It works for all isotropic models, some special models such as \command{\link{RMnsst}}, and multiplicative models that separate the time component. } } \value{ \code{RPtbm} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Turning bands \itemize{ \item Lantuejoul, C. (2002) \emph{Geostatistical Simulation: Models and Algorithms.} Springer. \item Matheron, G. (1973). The intrinsic random functions and their applications. \emph{Adv. Appl. Probab.}, \bold{5}, 439-468. \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } Turning layers \itemize{ \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. } } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## isotropic example that forces the use of the turning bands method model <- RPtbm(RMstable(s=1, alpha=1.8)) x <- seq(-3, 3, 0.1) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## anisotropic example that forces the use of the turning bands method model <- RPtbm(RMexp(Aniso=matrix(nc=2, rep(1,4)))) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## isotropic example that uses the turning layers method model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,5)) plot(z, MARGIN.slices=4, MARGIN.movie=3) \dontshow{FinalizeExample()}} \seealso{\link{Gaussian}, \link{RP}, \command{\link{RPspectral}}. } \keyword{methods} RandomFields/man/RMchoquet.Rd0000644000176200001440000000611613437301604015577 0ustar liggesusers\name{RMchoquet} \alias{RMchoquet} \alias{Choquet's representation} \alias{Schoenberg's representation} \title{Schoenberg's representation for the classes psi_d and \eqn{psi_{\infty}} in d=2} \description{ \command{\link{RMchoquet}} is an isotropic covariance model. The corresponding covariance function only depends on the angle \eqn{0 \le \theta \le \pi}{0 \le \theta \le \pi} between two points on the sphere and is given for d=2 by \deqn{\psi(\theta) = \sum_{n=0}^{\infty} b_{n,2}/(n+1)*P_n(cos(\theta)),} where \deqn{\sum_{n=0}^{\infty} b_{n,d}=1} and \eqn{P_n} is the Legendre Polynomial of integer order \eqn{n >= 0}{n >= 0}. } \usage{ RMchoquet(b) } \arguments{ \item{b}{a numerical vector of weights in \eqn{(0,1)}, such that sum(b)=1.} } \details{ By the results (cf. Gneiting, T. (2013), p.1333) of Schoenberg and others like Menegatto, Chen, Sun, Oliveira and Peron, the class \eqn{psi_d} of all real valued funcions on \eqn{[0,\pi]}, with \eqn{\psi(0)=1} and such that the associated isotropic function \deqn{h(x,y)=\psi(theta) with cos(\theta)=} \deqn{for x,y in {x in R^d: ||x|| = 1}} is (strictly) positive definite is represented by this covariance model. The model can be interpreted as Choquet representation in terms of extremal members, which are non-strictly positive definite. Special cases are the multiquadric family (see \command{\link{RMmultiquad}}) and the model of the sine power function (see \command{\link{RMsinepower}}). } \value{ \command{\link{RMchoquet}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T. (2013) \emph{Strictly and non-strictly positive definite functions on spheres.} Bernoulli, \bold{19}(4), 1327-1349. \item Schoenberg, I.J. (1942) \emph{Positive definite functions on spheres.} Duke Math.J.,\bold{9}, 96-108. \item Menegatto, V.A. (1994) \emph{Strictly positive definite kernels on the Hilbert sphere.} Appl. Anal., \bold{55}, 91-101. \item Chen, D., Menegatto, V.A., and Sun, X. (2003) \emph{A necessary and sufficient condition for strictly positive definite functions on spheres.} Proc. Amer. Math. Soc.,\bold{131}, 2733-2740. \item Menegatto, V.A., Oliveira, C.P. and Peron, A.P. (2006) \emph{Strictly positive definite kernels on subsets of the complex plane.} Comput. Math. Appl., \bold{51}, 1233-1250. } } \author{Christoph Berreth; \martin} \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{spherical models}}, \command{\link{RMmultiquad}}, \command{\link{RMsinepower}} } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## to do \dontshow{\dontrun{ #b = #model <- RMchoquet(b=b) #x <- seq(0, 10, 0.02) #plot(model) #plot(RFsimulate(model, x=x)) }} \dontshow{FinalizeExample()}}RandomFields/man/RRunif.Rd0000644000176200001440000000265013437301604015074 0ustar liggesusers\name{RRunif} \alias{RRunif} \title{Uniform Distribution in Higher Dimensions} \description{ The model refers to the d-dimensional uniform distribution on a rectangular window. } \usage{ RRunif(min, max, normed) } \arguments{ \item{min,max}{lower and upper corner of a rectangular window} \item{normed}{logical with default value \code{TRUE}. Advanced. If \code{FALSE} then the indicator function for the window is not normed to get a probability distribution. Nonetheless, random drawing from the distribution still works. } } \details{ In the one-dimensional case it has the same effect as \code{\link{RRdistr}(\link[=runif]{unif}(min=min, max=max, log=log))}. } \value{ \command{\link{RRunif}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RRdistr}}, \command{\link{RRgauss}}, \command{\link{RRspheric}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## uniform distribution on [0,2] x [-2, -1] RFrdistr(RRunif(c(0, -2), c(2, -1)), n=5, dim=2) RFpdistr(RRunif(c(0, -2), c(2, -1)), q=c(1, -1.5), dim=2) RFddistr(RRunif(c(0, -2), c(2, -1)), x=c(1, -1.5), dim=2) \dontshow{FinalizeExample()} } RandomFields/man/RMcutoff.Rd0000644000176200001440000000564613437301604015424 0ustar liggesusers\name{RMcutoff} \alias{RMcutoff} \title{Gneiting's modification towards finite range} \description{ \command{\link{RMcutoff}} is a functional on univariate stationary isotropic covariance functions \eqn{\phi}{phi}. The corresponding function \eqn{C} (which is not necessarily a covariance function, see details) only depends on the distance \eqn{r}{r} between two points in \eqn{d}-dimensional space and is given by \deqn{C(r)=\phi(r), 0\le r \le d} \deqn{C(r) = b_0 ((dR)^a - r^a)^{2 a}, d \le r \le dR} \deqn{C(r) = 0, dR \le r} The parameters \eqn{R} and \eqn{b_0} are chosen internally such that \eqn{C} is a smooth function. } \usage{ RMcutoff(phi, diameter, a, var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary isotropic covariance model. See, for instance, \code{RFgetModelNames(type="positive definite", domain="single variable", isotropy="isotropic", vdim=1)}. } \item{diameter}{a numerical value; should be greater than 0; the diameter of the domain on which the simulation is done} \item{a}{a numerical value; should be greater than 0; has been shown to be optimal for \eqn{a = 1/2} or \eqn{a =1}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The algorithm that checks the given parameters knows only about some few necessary conditions. Hence it is not ensured that the cutoff-model is a valid covariance function for any choice of \eqn{\phi} and the parameters. For certain models \eqn{\phi}{phi}, e.g. \command{\link{RMstable}}, \command{\link{RMwhittle}} and \command{\link{RMgencauchy}}, some sufficient conditions are known (cf. Gneiting et al. (2006)). } \value{ \command{\link{RMcutoff}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large {G}aussian Lattice Systems in {$R^2$}: Exploring the Limits. \emph{J. Comput. Graph. Stat.} \bold{15}, 483--501. \item Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599 } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() plot(model, model.cutoff=RMcutoff(model, diameter=1), xlim=c(0, 4)) model <- RMstable(alpha = 0.8) plot(model, model.cutoff=RMcutoff(model, diameter=2), xlim=c(0, 5)) x <- y <- seq(0, 4, 0.05) plot(RFsimulate(RMcutoff(model), x=x, y = y)) \dontshow{FinalizeExample()}}RandomFields/man/RMpenta.Rd0000644000176200001440000000332013437301604015230 0ustar liggesusers\name{RMpenta} \alias{RMpenta} \title{Penta Covariance Model} \description{ \command{\link{RMpenta}} is a stationary isotropic covariance model, which is only valid for dimensions \eqn{d \le 3}{d \le 3}. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (1 - \frac{22}{3}r^{2} + 33 r^{4} - \frac{77}{2} r^{5} + \frac{33}{2} r^{7} - \frac{11}{2} r^{9} + \frac{5}{6}r^{11}) 1_{[0,1]}(r) . }{C(r)=(1 - 22/3 r^{2} + 33 r^{4} - 77/2 r^{5} + 33/2 r^{7} - 11/2 r^{9} + 5/6 r^{11}) 1_{[0,1]}(r).} } \usage{ RMpenta(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model is only valid for dimensions \eqn{d \le 3}{d \le 3}. It has a 4 times differentiable covariance function with compact support (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 84). } \value{ \command{\link{RMpenta}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpenta() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RPt.Rd0000644000176200001440000000245513437301604014377 0ustar liggesusers\name{RPt} \alias{RPt} \title{Simulation of T Random Fields} \description{ \command{RPt} defines a t field. } \usage{ RPt(phi, boxcox, nu) } \arguments{ \item{phi}{the \command{\link{RMmodel}}. If a model for the distribution is not specified, \command{\link{RPgauss}} is used as default and a covariance model is expected.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{nu}{non-negative number. Degree of freedom.} } \value{ The function returns an object of class \code{\link[=RMmodel]{RMmodel}}. } \me \seealso{ \command{\link{Auxiliary RMmodels}}, \command{\link{RP}}, \command{\link{RPgauss}}. } \references{ Related to the extremal t process \itemize{ \item T. Opitz (2012) A spectral construction of the extremal t process. \emph{arxiv} \bold{1207.2296}. } } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPt(RMexp(), nu=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMangle.Rd0000644000176200001440000000464113437301604015216 0ustar liggesusers\name{RMangle} \alias{RMangle} \title{Anisotropy matrix given by angle} \description{ \command{RMangle} delivers an anisotropy matrix for the argument \code{Aniso} in \command{\link{RMmodel}} in two dimensions. \command{RMangle} requires one or two stretching values, passed by \code{ratio} or \code{diag}, and an \command{angle}. In two dimensions and with \code{angle} equal to \eqn{a} and \code{diag} equal to \eqn{(d1, d2)} the anisotropy matrix \eqn{A} is \code{A = diag(d1, d2) \%*\% matrix(ncol=2, c(cos(a), sin(a), -sin(a), cos(a)))} In three dimensions and with \code{angle} equal to \eqn{a}, second angle \eqn{L} and \code{diag} equal to \eqn{(d1, d2, d3)} the anisotropy matrix \eqn{A} is \code{A = diag(d1, d2, d3) \%*\% matrix(ncol=3, c(cos(a) * cos(L), sin(a) * cos(L), sin(L), -sin(a), cos(a), 0, -cos(a) * sin(L), -sin(a) * sin(L), cos(L) ))} i.e. \eqn{Ax} turns a vector x first in the \eqn{x-z} plane, then in the \eqn{x-y} plane. } \usage{ RMangle(angle, lat.angle, ratio, diag) } \arguments{ \item{angle}{angle \code{a}} \item{lat.angle}{second angle; in 3 dimensions only} \item{ratio}{equivalent to \code{diag=c(1, 1/ratio)}; in 2 dimensions only} \item{diag}{the diagonal components of the matrix} } \value{ \command{\link{RMangle}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMtrafo}}, \command{\link{RMmodel}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(Aniso=RMangle(angle=pi/4, ratio=3)) plot(model, dim=2) x <- seq(0, 2, 0.05) z <- RFsimulate(x, x, model=model) plot(z) model <- RMexp(Aniso=RMangle(angle=pi/4, lat.angle=pi/8, diag=c(1,2,3))) x <- seq(0, 2, 0.2) z <- RFsimulate(x, x, x, model=model) plot(z, MARGIN.slices=3) ## next model gives an example how to estimate the parameters back n <- 20 x <- runif(n, 0, 10) y <- runif(n, 0, 10) coords <- expand.grid(x, y) model <- RMexp(Aniso=RMangle(angle=pi/4, diag=c(1/4, 1/12))) d <- RFsimulate(model, x=coords[, 1], y=coords[, 2], n=10) estmodel <- RMexp(Aniso=RMangle(angle=NA, diag=c(NA, NA))) system.time(RFfit(estmodel, data=d, modus_operandi='sloppy')) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMcircular.Rd0000644000176200001440000000311313437301604015725 0ustar liggesusers\name{RMcircular} \alias{RMcircular} \title{Circular Covariance Model} \description{ \command{\link{RMcircular}} is a stationary isotropic covariance model which is only valid for dimensions \eqn{d \le 2 }{d \le 2 }. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = 1 - 2/\pi (r \sqrt(1-r^2) + arcsin(r)) 1_{[0,1]}(r).}{C(r) = 1 - 2/\pi (r \sqrt(1-r^2) + asin(r)) 1_{[0,1]}(r).} } \usage{ RMcircular(var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The model is only valid for dimensions \eqn{d \le 2 }{d \le 2}. It is a covariance function with compact support (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 82). } \value{ \command{\link{RMcircular}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcircular() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RPchi2.Rd0000644000176200001440000000217013437301604014753 0ustar liggesusers\name{RPchi2} \alias{RPchi2} \title{Simulation of Chi2 Random Fields} \description{ \command{RPchi2} defines a chi2 field. } \usage{ RPchi2(phi, boxcox, f) } \arguments{ \item{phi}{the \command{\link{RMmodel}}. If a model for the distribution is not specified, \command{\link{RPgauss}} is used as default and a covariance model is expected.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{f}{integer. Degree of freedom.} } \value{ The function returns an object of class \code{\link[=RMmodel]{RMmodel}}. } \me \seealso{ \command{\link{Auxiliary RMmodels}}, \command{\link{RP}}, \command{\link{RPgauss}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPchi2(RMexp(), f=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model=model, x, x, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMvector.Rd0000644000176200001440000000504113437301604015425 0ustar liggesusers\name{RMvector} \alias{RMvector} \title{Vector Covariance Model} \description{ \command{\link{RMvector}} is a multivariate covariance model which depends on a univariate covariance model that is stationary in the first \eqn{Dspace} coordinates \eqn{h}{h} and where the covariance function phi(h,t) is twice differentiable in the first component \eqn{h}{h}. The corresponding matrix-valued covariance function C of the model only depends on the difference \eqn{h}{h} between two points in the first component. It is given by \deqn{ C(h,t)=( -0.5 * (a + 1) \Delta + a \nabla \nabla^T ) C_0(h, t) } where the operator is applied to the first component \eqn{h}{h} only. } \usage{ RMvector(phi, a, Dspace, var, scale, Aniso, proj) } \arguments{ \item{phi}{an \command{\link{RMmodel}}; has two components \eqn{h}{h} (2- or 3-dimensional and stationary) and \eqn{t}{t} (arbitrary dimension).} \item{a}{a numerical value; should be in the interval \eqn{[-1,1]}.} \item{Dspace}{an integer; either 2 or 3; the first \eqn{Dspace} coordinates give the first component \eqn{h}{h}.} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ \eqn{C_0} is either a spatio-temporal model (then \eqn{t} is the time component) or it is an isotropic model. Then, the first \eqn{Dspace} coordinates are considered as \eqn{h} coordinates and the remaining ones as \eqn{t} coordinates. By default, \eqn{Dspace} equals the dimension of the field (and there is no \eqn{t} component). If \eqn{a=-1} then the field is curl free; if \eqn{a=1} then the field is divergence free. } \value{ \command{\link{RMvector}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. \emph{Stochastic Models} \bold{28:3}. } } \me \seealso{ \command{\link{RMcurlfree}}, \command{\link{RMdivfree}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMvector(RMgauss(), scale=0.3) x <- seq(0, 10, 0.4) plot(RFsimulate(model, x=x, y=x, z=0), select.variables=list(1:2)) \dontshow{FinalizeExample()}}RandomFields/man/RMmodelgenerator-class.Rd0000644000176200001440000002202113437301604020232 0ustar liggesusers\name{RMmodelgenerator-class} \docType{class} \alias{RMmodelgenerator-class} \alias{show,RMmodelgenerator-method} \alias{[,RMmodelgenerator-method} \alias{[,RMmodelgenerator,ANY,ANY-method} \alias{[,RMmodelgenerator,ANY,ANY,ANY-method} \alias{[<-,RMmodelgenerator,ANY,ANY-method} \alias{[<-,RMmodelgenerator,ANY,ANY,ANY-method} \alias{[<-,RMmodelgenerator-method} \alias{print.RMmodelgenerator} \title{Class \code{RMmodelgenerator} } \description{ Class for all functions of this package with prefix \code{RM}, i.e. all functions that generate objects of class \code{\link[=RMmodel-class]{RMmodel}}; direct extension of class \code{\link[methods:function-class]{function}}. } \section{Creating Objects}{ Objects should not be created by the user! } \section{Slots}{ \describe{ \item{\code{.Data}:}{function; the genuine function that generates an object of class \command{\link[=RMmodel-class]{RMmodel}} } \item{\code{type}:}{character string; specifies the category of RMmodel-function, see Details} \item{\code{domain}:}{character string; specifies whether the corresponding function(s) depend on 1 or 2 variables, see Details} \item{\code{isotropy}:}{character string; specifies the type of isotropy of the corresponding covariance model, see Details} \item{\code{operator}:}{logical; specifies whether the underlying covariance model is an operator, see Details} \item{\code{monotone}:}{character string; specifies the kind of monotonicity of the model} \item{\code{finiterange}:}{logical; specifies whether the underlying covariance model has finite range, see Details} % finiterange waere wuenschenswert an Abhaengigkeit von parametern % und submodellen anzupassen, siehe maxdim und vdim \item{\code{simpleArguments}:}{logical. If \code{TRUE} than all the parameters are real valued (or integer valued). } \item{\code{maxdim}:}{numeric; the maximal dimension, in which the corresponding model is a valid covariance model, see Details} \item{\code{vdim}:}{numeric; dimension of the value of the random field at a single fixed location, equals 1 in most cases, see Details} } } \section{Extends}{ Class \code{\link[methods:function-class]{function}}, directly. } \section{Methods}{ \describe{ \item{show}{\code{signature(x = CLASS_CLIST)}: returns the structure of \code{x}} \item{print}{\code{signature(x = CLASS_CLIST)}: identical with \command{show}-method} \item{[}{\code{signature(x = CLASS_RM)}: enables accessing the slots via the "["-operator, e.g. x["maxdim"]} \item{[<-}{\code{signature(x = CLASS_RM)}: enables replacing the slots via the "["-operator} } } \section{Details}{ \describe{ \item{\code{type}:}{can be one of the following strings: \describe{ \item{\code{'tail correlation function'}:}{ indicates that the function returns a tail correlation function (a subclass of the set of positive definite functions) } \item{\code{'positive definite'}:}{indicates that the function returns a covariance function (positive definite function)} \item{\code{'negative definite'}:}{indicates that the function returns a variogram model (negative definite function)} \item{\code{'process'}:}{functions of that type determine the class of processes to be simulated} \item{\code{'method for Gauss processes'}:}{methods to simulate Gaussian random fields} \item{\code{'method for Brown-Resnick processes'}:}{methods to simulate Brown-Resnick fields} \item{\code{'point-shape function'}:}{functions of that type determine the distribution of points in space} \item{\code{'distribution family'}:}{ e.g. (multivariate) uniform distribution, normal distribution, etc., defined in \pkg{RandomFields}. See \link{RR} for a complete list. } \item{\code{'shape function'}:}{functions used in, e.g., M3 processes (\link{RPsmith})} \item{\code{'trend'}:}{\link{RMtrend} or a \link[=RFformula]{mixed model} } \item{\code{'interface'}:}{indicates internal models which are usually not visible for the users. These functions are the internal representations of \command{\link{RFsimulate}}, \command{\link{RFcov}}, etc. See \link{RF} for a complete list. }%\item{\code{'undefinded'}:}{} \item{\code{'undefined'}:}{some models can take different types, depending on the parameter values and/or the submodels } \item{\code{'other type'}:}{very very special internal functions, not belonging to any of the above types. } } } \item{\code{domain}:}{can be one of the following strings: \describe{ \item{\code{'single variable'}:}{Function depending on a single variable} \item{\code{'kernel'}:}{model refers to a kernel, e.g. a non-stationary covariance function} \item{\code{'framework dependent'}:}{domain depends on the calling model} \item{\code{'mismatch'}:}{this option is used only internally and should never appear} } } \item{\code{isotropy}:}{can be one of the following strings: \describe{ \item{\code{'isotropic'}:}{indicates that the model is isotropic} \item{\code{'space-isotropic'}:}{indicates that the spatial part of a spatio-temporal model is isotropic} \item{\code{'zero-space-isotropic'}:}{this property refers to space-time models; the model is called zerospaceisotropic if it is isotropic as soon as the time-component is zero} \item{\code{'vector-isotropic'}:}{multivariate vector model (flow fields) have a different notion of isotropy} \item{\code{'symmetric'}:}{the most basic property of any covariance function or variogram model} \item{\code{'cartesian system'}, \code{'earth system'}, \code{'spherical system'}, \code{'cylinder system'}:}{ different coordinate systems } \item{\code{'non-dimension-reducing'}:}{the property \eqn{f(x) = f(-x)^\top} does not hold } \item{\code{'parameter dependent'}:}{indicates that the type of isotropy of the model depends on the parameters passed to the model; in particular parameters may be submodels if an operator model is considered} \item{\code{''}:}{this option is used only internally and should never appear} } } \item{\code{operator}:}{if \code{TRUE}, the model requires at least one submodel} \item{\code{monotone}:}{ \describe{ \item{\code{'mismatch in monotonicity'}:}{used if a statement on the monotonocity does not make sense, e.g. for \code{\link{RRmodels}} } \item{\code{'submodel dependent monotonicity'}:}{only for operators, e.g. \code{\link{RMS}}} \item{\code{'previous model dependent monotonicity'}:}{internal; should not be used} \item{\code{'parameter dependent monotonicity'}:}{some models change their properties according to the parameters} \item{\code{'not monotone'}:}{none of the above categories; either the function is not monotone or properties are unknown} \item{\code{'monotone'}:}{isotone or antitone} \item{\code{'Gneiting-Schaback class'}:}{function belonging to Euclid's hat in Gneiting's 1999 paper} \item{\code{'normal mixture'}:}{scale mixture of the Gaussian model} \item{\code{'completely monotone'}:}{completely monotone function} \item{\code{'Bernstein'}:}{Bernstein function} } Note that \itemize{ \item \code{'not monotone'} includes \code{'monotone'} and \code{'Bernstein'} \item \code{'monotone'} includes \code{'Gneiting-Schaback class'} \item \code{'Gneiting-Schaback class'} includes \code{'normal mixture'} \item \code{'normal mixture'} includes \code{'completely monotone'} } } \item{\code{finiterange}:}{if \code{TRUE}, the covariance of the model has finite range} \item{\code{maxdim}:}{if a positive integer, \code{maxdim} gives the maximum dimension in which the model is a valid covariance model, can be \code{Inf}; \code{maxdim=-1} means that the actual maxdim depends on the parameters; \code{maxdim=-2} means that the actual maxdim depends on the submodel(s)} \item{\code{vdim}:}{if a positive integer, \code{vdim} gives the dimension of the random field, i.e. univariate, bi-variate, ...; \code{vdim=-1} means that the actual vdim depends on the parameters; \code{vdim=-2} means that the actual vdim depends on the submodel(s)} } } \author{Alexander Malinowski, \martin} \references{ \itemize{ \item Gneiting, T. (1999) Radial positive definite functions generated by Euclid's hat, \emph{J. Multivariate Anal.}, \bold{69}, 88-119. } } \seealso{ \code{\link[=RMmodel-class]{RMmodel}}, \code{\link{RFgetModelNames}} } \keyword{classes} \keyword{hplot} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames() \dontshow{FinalizeExample()}} RandomFields/man/RMpower.Rd0000644000176200001440000000354613437301604015267 0ustar liggesusers\name{RMpower} \alias{RMpower} \alias{RMpower} \title{Power operator for Variograms and Covariance functions} \description{ \command{\link{RMpower}} yields a variogram or covariance model from a given variogram or covariance model. The variogram \eqn{\gamma}{gamma} of the model is given by \deqn{ \gamma = \phi^\alpha }{gamma=phi^alpha} if \eqn{\phi}{phi} is a variogram model. The covariance \eqn{C}{C} of the model is given by \deqn{ C(h) = \phi(0)-(\phi(0)-\phi(h))^\alpha }{C(h) = phi(0)-(phi(0)-phi(h))^alpha} if \eqn{\phi}{phi} is a covariance model. } \usage{ RMpower(phi, alpha, var, scale, Aniso, proj) } \arguments{ \item{phi}{a valid \command{\link{RMmodel}}; either a variogram model or a covariance model} \item{alpha}{a numerical value in the interval [0,1]} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ If \eqn{\gamma} is a variogram, then \eqn{\gamma^\alpha} is a valid variogram for \eqn{\alpha} in the interval [0,1]. } \value{ \command{\link{RMpower}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J. M., Schlather, M. \emph{Advances and Challenges in Space-time Modelling of Natural Events}, Springer, New York. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpower(RMgauss(), alpha=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RPcirculant.Rd0000644000176200001440000002402513437301604016115 0ustar liggesusers\name{Circulant Embedding} \alias{Circulant} \alias{RPcirculant} \alias{Cutoff} \alias{RPcutoff} \alias{Intrinsic} \alias{RPintrinsic} \title{Circulant Embedding methods} \description{ Circulant embedding is a fast simulation method for stationary (possibly anisotropic) Gaussian random fields on regular grids based on Fourier transformations. It is guaranteed to be an exact method for covariance functions with finite support, e.g. the spherical model. The method is admissible for any dimension apart from memory restrictions. \cr The simulation is performed on a torus which represents the bended grid. To remove wrong dependencies occuring at different borders of the grid which would be close on the torus, the simulation area is multiplied by a natural number. There is also a multivariate version of circulant embedding. Cut-off embedding is a fast simulation method for stationary, isotropic Gaussian random fields on square lattices based on the standard \command{\link{RPcirculant}} method, so that exact simulation is garantueed for further covariance models, e.g. the \command{\link{RMwhittle}} model. In fact, the circulant embedding is called with the cutoff hypermodel, see \command{\link{RMcutoff}}. \code{Cutoff} halfens the maximum number of elements models used to define the covariance function of interest (from 10 to 5). Here, multiplicative models are not allowed (yet). \cr For details see \command{\link{RMcutoff}}. Intrinsic embedding is a fast simulation method for intrinsically stationary, isotropic Gaussian random fields on square lattices based on the standard \command{\link{RPcirculant}} method, for further \emph{variogram} models, e.g. \command{\link{RMfbm}}. Note that the simulated random field is always \emph{non-stationary}. In fact, the circulant embedding is called with the Intrinsic hypermodel, see \command{\link{RMintrinsic}}. Here, multiplicative models are not allowed (yet). \cr For details see \command{\link{RMintrinsic}}. } \usage{ RPcirculant(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid) RPcutoff(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, a) RPintrinsic(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, rawR) } \arguments{ \item{phi}{See \command{\link{RPgauss}}.} % \item{loggauss}{See \command{\link{RPgauss}}} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } \item{force}{ Logical. Circulant embedding does not work if the constructed circulant matrix has negative eigenvalues. Sometimes it is convenient to replace all the negative eigenvalues by zero (\code{force=TRUE}) after \code{trials} number of trials. Default: \code{FALSE}. } \item{mmin}{Scalar or vector, integer if positive. \code{CE.mmin} determines the initial size of the circulant matrix. If \code{CE.mmin=0} the minimal starting size is determined automatically according to the dimensions of the grid. If \code{CE.mmin>0} then the absolute starting size is given. If \code{CE.mmin<0} then the automatically determined matrix size is multiplied by \eqn{|\code{CE.mmin}|}; here, \code{CE.mmin} must be smaller than -1; the value -1 takes over the minimal starting size.\cr Note: in any cases, the initial size might be increased according to \code{CE.useprimes}.\cr Default: \code{0}. } \item{strategy}{Logical. \code{0}: If the circulant matrix has negative eigenvalues then the size in each direction is doubled; \cr \code{1}: The size is enhanced only in one direction, namely that one where the covariance function has the largest value at the end point of the grid --- note that the default value of \code{trials} is probably too small in that case. In some cases \code{strategy=0} works better, in other cases \code{strategy=1}. Just try. Clearly, if the field is isotropic and a square grid should be simulated, then \code{strategy=0} is the better choice. Default: \code{0}. } \item{maxGB}{Maximal memory used for the circulant matrix in units of GB. If this argument is set then \code{maxmem} is set to MAXINT. Default: 1. } \item{maxmem}{Integer. maximal number of entries in a row of the circulant matrix. The total amount of memory needed for the internal calculations is %about 16 (=2 * sizeof(double)) % times as large as \code{maxmem} % if \code{\link{RFoptions}}\code{()$Storing=FALSE}, and 32 (= 4 * sizeof(double)) time as large (factor 2 is needed as complex numbers must be considered for calculating the fft of the covariance matrix; another factor 2 is needed for storing the simulated result). %if \code{Storing=TRUE}. The value of \code{maxmem} must be at least \eqn{2^d} times as large as the number of points to be simulated. Here, \eqn{d} is the space dimension. In some cases even much larger. Note that \code{maxmem} can be used to control the automatic choice of the simulation algorithm. Namely, in case of huge circulant matrices, other simulation methods (TBM) might be faster and might be preferred by the user. If this argument is set then \code{maxGB} is set to \code{Inf}. Default: \code{MAXINT}. } \item{tolIm}{ If the modulus of the imaginary part is less than \code{tolIm} then the eigenvalue is always considered as real (independently of the value of \code{force}). Default: \code{1E-3}. } \item{tolRe}{ Eigenvalues between \code{tolRe} and 0 are always considered as 0 and set 0 (independently of the value of \code{force}). Default: \code{-1E-7}. } \item{trials}{Integer. A larger circulant matrix is likely to make more eigenvalues non-negative. If at least one of the thresholds \code{tolRe} and \code{tolIm} are missed then the matrix size is doubled according to \code{strategy}, and the matrix is checked again. This procedure is repeated up to \code{trials - 1} times. If there are still negative eigenvalues, the simulation method fails if \code{force=FALSE}. Default: \code{3}. } \item{useprimes}{Logical. If \code{FALSE} the columns of the circulant matrix have length \eqn{2^k} for some \eqn{k}. Otherwise the algorithm tries to find a nicely factorizable number close to the size of the given matrix. Default: \code{TRUE}. } \item{dependent}{Logical. If \code{FALSE} then independent random fields are created. If \code{TRUE} then at least 4 non-overlapping rectangles are taken out of the the expanded grid defined by the circulant matrix. These simulations are dependent. See \link{RFoptionsAdvanced} for an example. See \code{trials} for some more information on the circulant matrix. Default: \code{FALSE}. } \item{approx_step}{Real value. It gives the grid size of the approximating grid in case circulant embedding is used although the points do not lie on a grid. If \code{NA} then \code{approx_step} is chosen such that \code{approx_maxgrid} is nearly reached. Default: \code{NA}. } \item{approx_maxgrid}{ It defaults to \code{maxmem}. } \item{diameter}{See \command{\link{RMcutoff}} or \command{\link{RMintrinsic}}.} \item{a}{See \command{\link{RMcutoff}}.} \item{rawR}{See \command{\link{RMintrinsic}}.} } \details{ Here, the algorithms by Dietrich and Newsam are implemented. } \value{ An object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Circulant Embedding \itemize{ \item Chan, G. and Wood, A.T.A. (1997) An Algorithm for Simulating Stationary Gaussian Random Fields. \emph{Journal of the Royal Statistical Society: Series C (Applied Statistics)}, \bold{46}, 171--181. \item Dietrich, C. R. and G. N. Newsam (1993) A fast and exact method for multidimensional gaussian stochastic simulations. \emph{Water Resour. Res.} \bold{29(8)}, 2861--2869. \item Dietrich, C. R. and G. N. Newsam (1996) A fast and exact method for multidimensional Gaussian stochastic simulations: Extension to realizations conditioned on direct and indirect measurements \emph{Water Resour. Res.} \bold{32(6)}, 1643--1652. \item Dietrich, C. R. and Newsam, G. N. (1997) Fast and Exact Simulation of Stationary Gaussian Processes through Circulant Embedding of the Covariance Matrix. \emph{SIAM J. Sci. Comput.} \bold{18}, 1088--1107. \item Wood, A. T. A. and Chan, G. (1994) Simulation of Stationary Gaussian Processes in \eqn{[0, 1]^d}. \emph{Journal of Computational and Graphical Statistics} \bold{3}, 409--432. } Cutoff and Intrinsic \itemize{ \item Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large {G}aussian Lattice Systems in {$R^2$}: Exploring the Limits. \emph{J. Comput. Graph. Stat.} \bold{15}, 483--501. \item Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. \emph{J. Comput. Graph. Statist.} \bold{11}, 587--599 } } \me \seealso{ \link{Gaussian}, \link{RP} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(s=1, alpha=1.8) x <- seq(-3,3,0.1) \dontshow{if (!interactive()){print("x values changed"); x <- -1:1}} z <- RFsimulate(model=RPcirculant(model), x=x, y=x, n=1) plot(z) model <- RMexp(var=10, s=2) z <- RFsimulate(model=RPcirculant(model), 1:10) plot(z) model <- RMfbm(Aniso=diag(c(1,2)), alpha=1.5) z <- RFsimulate(model, x=1:10, y=1:10) plot(z) \dontshow{FinalizeExample()}} \keyword{methods} RandomFields/man/RMmodelsNonstatationary.Rd0000644000176200001440000000253313437301604020527 0ustar liggesusers\name{RMmodelsNonstationary} \alias{RMmodelsNonstationary} \alias{Nonstationary RMmodels} \alias{non-stationary RMmodels} \alias{non-stationary} \title{Non-stationary features of the models} \description{ Here, non-stationary covariance models are presented. } \details{ \bold{Covariance models} \tabular{ll}{ \command{\link{RMnonstwm}} \tab one of Stein's non-stationary Whittle-Matern models \cr \command{\link{RMprod}} \tab scalar product \cr \code{\link[=RMS]{Aniso}} \tab for space transformation, see the example in \link{R.models}. \cr \code{scale}, cf. \command{\link{RMS}}, can be any non-negative function for any scale mixture model, such as the \link{whittle-matern}-classes, the \link{powered exponential} family, and the \command{\link{RMgencauchy}} model. } \bold{Trend models} See \link{RMmodelsTrend}. } \seealso{\command{\link{RFformula}}, \command{\link{RMmodels}}, \command{\link{RM}}, \command{\link{RMmodelsAdvanced}} \sQuote{\href{../doc/nonstationary_jss.pdf}{nonstationary}}, a vignette for non-stationary geostatistics } \me \keyword{spatial} \examples{\dontshow{StartExample()} %RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set %## RFoptions(seed=NA) to make them all random again # to do \dontshow{FinalizeExample()}} RandomFields/man/CoordinateSystems.Rd0000644000176200001440000002353113437301604017347 0ustar liggesusers\name{Coordinate systems} \alias{zenit} \alias{Coordinate systems} \alias{coordinate systems} \alias{coordinate system} \alias{coordinates} \title{Coordinate systems} \description{ Implemented Coordinate Systems. } \section{Implemented coordinate systems}{ \itemize{ \item Cartesian coordinate system \item Earth coordinate systems\cr The earth is considered as an ellipsoid; The first angle takes values in \eqn{[0, 360)}, the second angle takes values in \eqn{[-90, 90]}. \item Spherical coordinate systems\cr The earth is considered as an ellipsoid; The first angle takes values in \eqn{[0, 2\pi)}, the second angle takes values in \eqn{[-\pi/2, \pi/2]}. } } \section{Transformations between the system}{ \itemize{ \item Earth to cartesian\cr The 3-dimensional resulting coordinates are either given in \sQuote{km} or in \sQuote{miles}. \item Gnomonic and orthographic projections\cr The 2-dimensional resulting coordinates are either given in \sQuote{km} or in \sQuote{miles}. The projection direction is given by the \code{zenit}. \item Earth to spherical\cr In this case the Earth is considered as a ball. } Cartesian systems cannot be transformed to earth or spherical coordinate systems, nor a spherical system to earth coordinates. } \section{Options}{ \describe{ \item{\code{coord_system}}{character. One of the values \code{"auto"}, \code{"cartesian"}, \code{"earth"} % \code{"polar"}, \code{"cylindric"}, \code{"spherical"}, If \code{"auto"}, then the coordinates are considered as \code{"cartesian"} except the names of the given coordinates indicate a different system. Currently, only \code{"longitude"} and \code{"latidute"} (or abbreviations of them) are excepted as names for given coordinates and indicate an earth coordinate systems. See the examples below. Default: \code{"auto"} } \item{\code{coordidx}}{integer vector of column numbers of the variables in the data frame. \code{varidx} can be set alternatively to \code{coordnames}. This parameter gives the coordinate columns in a data frame by starting column and ending column or the sequence. An \code{NA} in the second component means \sQuote{until the end}. } \item{\code{coordnames}}{vector of characters that can be set alternatively to coordidx. This parameter gives the coordinate columns in a data frame by names. If it is \code{"NA"}, then, depending on the context, either an error message is returned or it is assumed that the first columns give the coordinates. } \item{\code{coordunits}}{any string. If \code{coordinate_system = "earth"} and longitude and latitude are transformed to 3d cartesian coordinates, \code{coordunits} determines whether the radius is given in kilometers (\code{"km"}) or miles (\code{"miles"}). If empty, then \code{"km"} is chosen. Default: \code{""} } \item{\code{new_coord_system}}{ One of the values \code{"keep"}, \code{"cartesian"}, \code{"earth"}, \code{"plane"}. % \code{"polar"}, \code{"cylindric"}, \code{"spherical"}, \enumerate{ \item \code{"keep"}\cr The \code{coord_system} is kept (except an explicit transformation is given, see \command{\link{RMtrafo}}. Note that some classes of models, e.g. completely monotone functions and compactly supported covariance models with range less than \eqn{\pi} are valid models on a sphere. In this case the models are considered as models on the sphere. See \link{spherical models} for lists. \item \code{"cartesian"}\cr If \code{coord_system} is \code{"earth"} the coordinates are transformed to cartesian coordinates before any model is considered. \item \code{"orthographic"}, \code{"genomic"} \cr If \code{coord_system} is \code{"earth"} the locations are projected to a plane before any model is considered. } Default: \code{"keep"} } \item{\code{new_coordunits}}{internal and should not be set by the user. Default: \code{""} } \item{\code{polar_coord}}{logical. If \code{FALSE} the spherical coordinates agree with the earth coordinate parametrization, except that radians are used for spherical coordinates instead of degrees for the earth coordinates. If \code{TRUE} the spherical coordinates signify polar coordinates. Default : \code{FALSE} } \item{\code{varidx}}{integer vector of length 2. \code{varidx} can be set alternatively to \code{varnames}. This parameter gives the data columns in a data frame, either by starting column and ending column. An \code{NA} in the second component means \sQuote{until the end}. } \item{\code{varnames}}{vector of characters that can be set alternatively to \code{varidx}. This parameter gives the data columns in a data frame by names. if \code{varnames} equals \code{"NA"} then for keywords \sQuote{data}, \sQuote{value} and \sQuote{variable} will be searched for keywords. If none of them are found, depending on the context, either an error message is returned or it is assumed that the last columns give the data. } \item{\code{varunits}}{vector of characters. The default units of the variables. Default: \code{""} } \item{\code{xyz_notation}}{logical or \code{NA}. Used by \code{\link{RMuser}} only. \code{NA} : automatic choice (if possible) \code{FALSE} : notation (x, y) should not be understood as kernel definition, not as xyz notation \code{TRUE}: xyz notation used % \code{2}:this value is only used by calls of RFcov and should not % be used by a user } \item{\code{zenit}}{two angles of the central projection direction for the gnomonic projection (\url{http://en.wikipedia.org/wiki/Gnomonic_projection}, \url{http://de.wikipedia.org/wiki/Gnomonische_Projektion}) and the orthographic projection, (\url{http://en.wikipedia.org/wiki/Orthographic_projection_in_cartography}, \url{http://de.wikipedia.org/wiki/Orthografische_Azimutalprojektion}). If \code{any(is.na(zenit))} then either the value of either of the components may not be \code{NA}, whose value will be denoted by \eqn{p}. If \eqn{p=1} then the mean of the locations is calculated; if \eqn{p=Inf} then the mean of the range is calculated. Default: \code{c(1, NA)} } } } \references{ Covariance models in a cartesian system \itemize{ \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. } Covariance models on a sphere \itemize{ \item Gneiting, T. (2013) Strictly and non-strictly positive definite functions on spheres. \emph{Bernoulli}, \bold{19}, 1327-1349. } Tail correlation function \itemize{ \item Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. \emph{Extremes}, \bold{} Submitted. } } \seealso{ \command{\link{RMtrafo}}, \command{\link{RFearth2cartesian}}, \command{\link{RPdirect}}, \command{\link[=spherical models]{models valid on a sphere}}, \command{\link{RFoptions}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 1:4 x <- cbind(z, 0) y <- cbind(0, z) model <- RMwhittle(nu=0.5) RFcov(model, x, y, grid=FALSE) ## standard is (cartesian) model ## same as above, but explicit: RFcov(model, x, y, grid=FALSE, coord_sys="cartesian") ## model is not valid on a sphere; x,y coordinates are ## transformed from earth coordinates to spherical coordinates RFcov(model, x, y, grid=FALSE, coord_sys="earth") ## now the scale is chosen such that the covariance ## values are comparable to those in the cartesian case RFcov(RMS(model, s= 1 / 180 * pi), x, y, grid=FALSE, coord_sys="earth") ## projection onto a plane first. Then the scale is interpreted ## in the usual, i.e. cartesian, sense, i.e. the model does not ## really make sense RFoptions(zenit = c(2.5, 2.5)) RFcov(model, x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic") ## again, here the scale is chosen to be comparable to the cartesian case ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic", new_coordunits="miles")) stopifnot(all.equal(z1, z2)) ## again, projection onto a plane first, but now using the ## gnomonic projection ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic", new_coordunits="miles")) stopifnot(all.equal(z1, z2, tol=1e-5)) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RPdirect.Rd0000644000176200001440000000346313437301604015406 0ustar liggesusers\name{Square root} \alias{Direct} \alias{RPdirect} \title{Methods relying on square roots of the covariance matrix} \description{ Methods relying on square roots of the covariance matrix } \usage{ RPdirect(phi, boxcox) } \arguments{ \item{phi}{object of class \code{\link[=RMmodel-class]{RMmodel}}; specifies the covariance model to be simulated.} \item{boxcox}{the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. See \command{\link{RFboxcox}} for details. } } \details{ \command{RPdirect} is based on the well-known method for simulating any multivariate Gaussian distribution, using the square root of the covariance matrix. The method is pretty slow and limited to about 12000 points, i.e. a 20x20x20 grid in three dimensions. This implementation can use the Cholesky decomposition and the singular value decomposition. It allows for arbitrary points and arbitrary grids. } \value{ \command{\link{RPdirect}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Schlather, M. (1999) \emph{An introduction to positive definite functions and to unconditional simulation of random fields.} Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University. }} \me \seealso{ \link{Gaussian}, \link{RP}, \link{RPsequential}. } \keyword{methods} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPdirect(model), 0:10, 0:10, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RPschlather.Rd0000644000176200001440000000554313437301604016112 0ustar liggesusers\name{ExtremalGaussian} \alias{RPschlather} \alias{extremal Gaussian} \alias{extremal Gaussian process} \title{Extremal Gaussian process} \description{ \command{RPschlather} defines an extremal Gaussian process. } \usage{ RPschlather(phi, tcf, xi, mu, s) } \arguments{ \item{phi}{an \command{\link{RMmodel}}, see Details.} \item{tcf}{an \command{\link{RMmodel}} specifying the extremal correlation function; either \code{phi} or \code{tcf} must be given.} \item{xi,mu,s}{the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. } } \details{ \GEV The argument \code{phi} can be any random field for which the expectation of the positive part is known at the origin. It simulates an Extremal Gaussian process \eqn{Z} (also called \dQuote{Schlather model}), which is defined by \deqn{Z(x) = \max_{i=1}^\infty X_i \max(0, Y_i(x)), }{Z(x) = max_{i=1, 2, ...} X_i * max(0, Y_i(x)),} where the \eqn{X_i} are the points of a Poisson point process on the positive real half-axis with intensity \eqn{c x^{-2} dx}{c/x^2 dx}, \eqn{Y_i \sim Y}{Y_i ~ Y} are iid stationary Gaussian processes with a covariance function given by \code{phi}, and \eqn{c} is chosen such that \eqn{Z} has standard Frechet margins. \code{phi} must represent a stationary covariance model. } \note{Advanced options are \code{maxpoints} and \code{max_gauss}, see \command{\link{RFoptions}}.} \me \seealso{ \command{\link{RMmodel}}, \command{\link{RPgauss}}, \command{\link{maxstable}}, \command{\link{maxstableAdvanced}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0, xi=0) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi=0: any simulated max-stable random field has extreme value index 0 x <- seq(0, 2,0.01) ## standard use of RPschlather (i.e. a standardized Gaussian field) model <- RMgauss() z1 <- RFsimulate(RPschlather(model), x) plot(z1, type="l") ## the following refers to the generalized use of RPschlather, where ## any random field can be used. Note that 'z1' and 'z2' have the same ## margins and the same .Random.seed (and the same simulation method), ## hence the same values model <- RPgauss(RMgauss(var=2)) z2 <- RFsimulate(RPschlather(model), x) plot(z2, type="l") all.equal(z1, z2) # true ## Note that the following definition is incorrect try(RFsimulate(model=RPschlather(RMgauss(var=2)), x=x)) ## check whether the marginal distribution (Gumbel) is indeed correct: model <- RMgauss() z <- RFsimulate(RPschlather(model, xi=0), x, n=100) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) \dontshow{FinalizeExample()}} RandomFields/man/RC.Rd0000644000176200001440000001010313437301604014163 0ustar liggesusers\name{Constants} \alias{constants} \alias{RC} \alias{RC_ISOTROPIC} \alias{RC_ISO_NAMES} \alias{RC_TYPE_NAMES} \alias{RC_DOMAIN_NAMES} \alias{RC_MONOTONE_NAMES} \alias{RC_SPACEISOTROPIC} \alias{RC_CARTESIAN_COORD} \alias{RC_GNOMONIC_PROJ} \alias{RC_ORTHOGRAPHIC_PROJ} \alias{RC_EARTH_COORDS} \alias{RC_SPHERICAL_COORDS} \alias{RC_OPTIMISER_NAMES} \alias{RC_NLOPTR_NAMES} \alias{RC_LIKELIHOOD_NAMES} \alias{RC_EARTH_ISOTROPIC} \alias{RC_DOUBLEISOTROPIC} \alias{RC_EARTH_ISOTROPIC} \alias{RC_UNREDUCED} \title{Constants used in RandomFields (RC constants)} \description{ Several constants are provided that might make the use of some functions easier, e.g. \command{\link{RFgetModelNames}}. } \value{ \code{RC_TYPE_NAMES = c( "tail correlation", "positive definite", "variogram", "negative definite", "point-shape function", "shape function", "trend", "distribution or shape", "of manifold type", "process", "method for Gauss process", "normed process (non-negative values with maximum value being 0 or 1)", "method for Brown-Resnick process", "Smith", "Schlather", "Poisson", "PoissonGauss", "distribution family", "interface", "mathematical operator", "other type") } \code{RC_DOMAIN_NAMES = c("single variable", "kernel", "framework dependent", "submodel dependent", "parameter dependent", "", "mismatch") } \code{RC_ISO_NAMES = c("isotropic", "space-isotropic", "vector-isotropic", "symmetric", "cartesian system", "gnomonic projection", "orthographic projection", "spherical isotropic", "spherical symmetric", "spherical system", "earth isotropic", "earth symmetric", "earth system", "cylinder system", "non-dimension-reducing", "framework dependent", "submodel dependent", "parameter dependent", "", "") } \code{RC_MONOTONE_NAMES = c( "not set", "mismatch in monotonicity", "submodel dependent monotonicity", "previous model dependent monotonicity", "parameter dependent monotonicity", "not monotone", "monotone", "Gneiting-Schaback class", "normal mixture", "completely monotone", "Bernstein") } \code{RC_ISOTROPIC} gives the numerical code for option \code{"isotropic"} \code{RC_DOUBLEISOTROPIC} gives the numerical code for option \code{"space-isotropic"} \code{RC_CARTESIAN_COORD} gives the numerical code for option \code{"cartesian system"} \code{RC_GNOMONIC_PROJ} gives the numerical code for the gnomonic projection, see also \code{zenit} in \code{\link{RFoptions}}. \code{RC_ORTHOGRAPHIC_PROJ} gives the numerical code for the orthographic projection, see also \code{zenit} in \code{\link{RFoptions}}. \code{RC_EARTH_COORDS} gives the numerical code for option \code{"earth coordinates"} \code{RC_EARTH_ISOTROPIC} gives the numerical code for option \code{"earth isotropic"} \code{RC_SPHERICAL_COORDS} gives the numerical code for option \code{"earth coordinates"} \code{RC_OPTIMISER_NAMES} and \code{RC_NLOPTR_NAMES} give the names for the options \code{optimiser} and \code{algorithm}, respectively, \code{RFfitoptimiser}. \code{RC_LIKELIHOOD_NAMES = c("auto", "full", "composite", "tesselation")} gives the names of the ML variants: (i) internal choice according to the number of data, (ii) full likelihood, (iii) (pairwise) composite likelihood, and (iv) composite likelihood based on a tessellation of the space. } \seealso{ \link{RF}, \link{RM}, \link{RP}, \link{RR}, \link{R.}, \command{\link{RFgetModelNames}}, \link{RMmodelgenerator-class}, \command{\link{RMtrafo}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RC_ISO_NAMES RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1] \dontrun{ RFgetModelNames(isotropy=RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1]) } \dontshow{FinalizeExample()}} RandomFields/man/PrintModelList.Rd0000644000176200001440000000330513437301604016576 0ustar liggesusers\name{PrintModelList} \alias{PrintModelList} \alias{GetModelList} \alias{GetModelNames} \title{Information about the implemented covariance models} \description{ \code{PrintModelList} prints the list of currently implemented models including the corresponding simulation methods. } \usage{ PrintModelList(operators=FALSE, internal=FALSE, newstyle=TRUE) } \arguments{ \item{operators}{logical. Flag whether operators should also be considered. } \item{internal}{logical. Flag whether internal models should also be considered. In case of \command{PrintModelList} and \code{internal=2}, variants of internal models are also printed. } \item{newstyle}{ logical. If \code{FALSE} then only the old style model names (Version 2 and earlier) are shown. These names can still be used in the list definition of models, see \link{RMmodelsAdvanced}. If \code{TRUE} then the standard names will also be shown. } } \value{ \code{PrintModelList} prints a table of the currently implemented covariance functions and the matching methods. \code{PrintModelList} returns \code{NULL}. } \details{ See \link{RMmodel} for a description of the models and their use. } \note{ From version 3.0 on, the command \code{PrintModelList()} is replaced by the call \code{\link{RFgetModelNames}(internal=FALSE)}. } \me \seealso{ \command{\link{RFgetModelNames}} } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again % library(RandomFields) PrintModelList() \dontshow{FinalizeExample()}} %getOption("device")RandomFields/man/RFsimulate.Rd0000644000176200001440000002044213437301604015741 0ustar liggesusers\name{RFsimulate} \alias{RFsimulate} \title{Simulation of Random Fields} \description{ This function simulates \bold{unconditional} random fields: \itemize{ \item univariate and multivariate, spatial and spatio-temporal \link[=Gaussian]{Gaussian random fields} \item fields based on Gaussian fields such as \link[=RPchi2]{Chi2 fields} or \link[=RPbernoulli]{Binary fields}, see \link{RP}. \item \link[=RPpoisson]{stationary Poisson fields} \item \link[=RPmaxstable]{stationary max-stable random fields}. } It also simulates \bold{conditional} random fields for \itemize{ \item univariate and multivariate, spatial and spatio-temporal Gaussian random fields } Here, only the simulation of Gaussian random fields is described. For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see \link{RFsimulateAdvanced}. } \usage{ RFsimulate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, distances, dim, data, given=NULL, err.model, params, err.params, n=1, ...) } \arguments{ \item{model,params}{\argModel % \itemize{ % \item if of class \code{\link[=RMmodel-class]{RMmodel}}, \code{model} % specifies a covariance or variogram model of a Gaussian random field; % type \code{\link{RFgetModelNames}(type="variogram")} for a list of % available models; see also \command{\link{RMmodel}}. % % \item if of class \code{\link{RFformula}} or % \code{\link[methods:formula-class]{formula}} , % \code{submodel} specifies a linear mixed model where random % effects can be modelled by Gaussian random fields; % see \command{\link{RFformula}} for details on model % specification. % % \item for (many) more options see \link{RFsimulateAdvanced}. % } } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{data}{For conditional simulation and random imputing only. If \code{data} is missing, unconditional simulation is performed.\cr \argData \argDataGiven If the argument \code{x} is missing, \code{data} may contain \code{NA}s, which are then replaced by conditionally simulated values (random imputing); } \item{given}{\argGiven } \item{err.model,err.params}{For conditional simulation and random imputing only.\cr\argErrmodel.} \item{n}{number of realizations to generate. For a very advanced feature, see the notes in \link{RFsimulateAdvanced}. } \item{...}{\argDots} } \details{ By default, all Gaussian random fields have zero mean. Simulating with trend can be done by including \command{\link{RMtrend}} in the model, see the examples below. If \code{data} is passed, conditional simulation based on simple kriging is performed: \itemize{ \item If of class \code{\link[=RFsp-class]{RFsp}}, \code{ncol(data@coords)} must equal the dimension of the index space. If \code{data@data} contains only a single variable, variable names are optional. If \code{data@data} contains more than one variable, variables must be named and \code{model} must be given in the tilde notation \code{resp ~ ... } (see \command{\link{RFformula}}) and \code{"resp"} must be contained in \code{names(data@data)}. \item % Beschreibung hier stimmt nicht so ganz mit Examples unten ueberein If \code{data} is a matrix or a data.frame, either \code{ncol(data)} equals \eqn{(dimension of index space + 1)} and the order of the columns is (x, y, z, T, response) or, if \code{data} contains more than one response variable (i.e. \code{ncol(data) > (dimension of index space + 1)}), \code{colnames(data)} must contain \code{colnames(x)} or those of \code{"x", "y", "z", "T"} that are not missing. The response variable name is matched with \code{model}, which must be given in the tilde notation. If \code{"x", "y", "z", "T"} are missing and \code{data} contains \code{NA}s, \code{colnames(data)} must contain an element which starts with \sQuote{data}; the corresponding column and those behind it are interpreted as the given data and those before the corresponding column are interpreted as the coordinates. \item If \code{x} is missing, \command{\link{RFsimulate}} searches for \code{NA}s in the data and performs a conditional simulation for them. } Specification of \code{err.model}: In geostatistics we have two different interpretations of a nugget effect: small scale variability and measurement error. The result of conditional simulation usually does not include the measurement error. Hence the measurement error \code{err.model} must be given separately. For sake of generality, any model (and not only the nugget effect) is allowed. Consequently, \code{err.model} is ignored when unconditional simulation is performed. } \value{By default, an object of the virtual class \command{\link[=RFsp-class]{RFsp}}; result is of class \code{\link[=RMmodel-class]{RMmodel}}. \itemize{ \item \command{\link[=RFspatialGridDataFrame]{RFspatialGridDataFrame}} if the space-time dimension is greater than 1 and the coordinates are on a grid, \item \command{\link[=RFgridDataFrame]{RFgridDataFrame}} if the space-time dimension equals 1 and the coordinates are on a grid, \item \command{\link[=RFspatialPointsDataFrame]{RFspatialPointsDataFrame}} if the space-time dimension is greater than 1 and the coordinates are not on a grid, \item \command{\link[=RFpointsDataFrame]{RFpointsDataFrame}} if the space-time dimension equals 1 and the coordinates are not on a grid. } In case of a multivariate If \code{n > 1} the repetitions make the last dimension. See \link{RFsimulateAdvanced} for additional options. } \references{ \litLantue \litIntro See \link{RFsimulateAdvanced} for more specific literature. } \note{Several advanced options can be found in sections \sQuote{General options} and \sQuote{coords} of \command{\link{RFoptions}}. In particular, option \code{spConform=FALSE} leads to a simpler (and faster!) output, see \command{\link{RFoptions}} for details. } \me \seealso{ \command{\link{RFvariogram}}, \command{\link{RFfit}}, \command{\link{RFgetModelInfo}}, \command{\link{RFgui}}, \command{\link{RMmodel}}, \command{\link{RFoptions}}, \command{\link{RFsimulateAdvanced}}, \command{\link{RFsimulate.more.examples}} } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ############################################################# ## ## ## ONLY TWO VERY BASIC EXAMPLES ARE GIVEN HERE ## ## see ## ## ?RMsimulate.more.examples ## ## and ## ## ?RFsimulateAdvanced ## ## for more examples ## ## ## ############################################################# ############################################################# ## ## ## Unconditional simulation ## ## ## ############################################################# ## first let us look at the list of implemented models RFgetModelNames(type="positive definite", domain="single variable", iso="isotropic") ## our choice is the exponential model; ## the model includes nugget effect and the mean: model <- RMexp(var=5, scale=10) + # with variance 4 and scale 10 RMnugget(var=1) + # nugget RMtrend(mean=0.5) # and mean ## define the locations: from <- 0 to <- 20 x.seq <- seq(from, to, length=200) y.seq <- seq(from, to, length=200) simu <- RFsimulate(model, x=x.seq, y=y.seq) plot(simu) ############################################################# ## ## ## Conditional simulation ## ## ## ############################################################# # first we simulate some random values at # 100 random locations: n <- 100 x <- runif(n=n, min=-1, max=1) y <- runif(n=n, min=-1, max=1) dta <- RFsimulate(model = RMexp(), x=x, y=y, grid=FALSE) plot(dta) # let simulate a field conditional on the above data L <- if (interactive()) 100 else 5 x.seq.cond <- y.seq.cond <- seq(-1.5, 1.5, length=L) model <- RMexp() cond <- RFsimulate(model, x=x.seq.cond, y=y.seq.cond, data=dta) plot(cond, dta) \dontshow{FinalizeExample()}} RandomFields/man/MajorRevisions.Rd0000644000176200001440000001053413437301604016641 0ustar liggesusers\name{Major Revisions} \alias{MajorRevisions} \title{Documentation of major changings} \description{ This man page documents some major changings in RandomFields. } \section{Changes done in 3.1.0 (Summer 2015)}{ \itemize{ \item full (univariate) trend modelling \item error in particular in \command{\link{RFfit}} corrected \item \command{\link{RFfit}} runs much faster now \item effects of \code{modus operandi} changed for estimating } } \section{Corrections done in 3.0.56 (Jan 2015)}{ \itemize{ \item log Gauss field corrected (has been a log log Gauss field) \item \command{RMconstant} is now called \command{\link{RMfixcov}} } } \section{Corrections done in 3.0.55 (Jan 2015)}{ \itemize{ \item Conditional simulation: several severe typos corrected. } } \section{Major Revision: changings from Version 2 to Version 3 (Jan 2014)}{ \itemize{ \item \bold{S4 objects} \itemize{ \item \pkg{RandomFields} is now based on S4 objects using the package \pkg{sp}. The functions accept both \pkg{sp} objects and simple objects as used in version 2. See also above. } \item\bold{Documentation} \itemize{ \item each model has now its own man page; \item classes of models and functions are bundled in several pages: Covariance models start with \code{\link{RM}}, distribution families with \code{\link{RR}}, processes with \code{\link{RP}}, user functions with \code{\link{RF}} \item the man pages of several functions are split into two parts: (i) a beginners man page which includes a link to (ii) man pages for advanced users } \item\bold{Interfaces} \itemize{ \item The interfaces become simpler, at the same time more powerful than the functions in version 2. E.g., \code{RFsimulate} can perform unconditional simulation, conditional simulation and random imputing. \item Only those arguments are kept in the functions that are considered as being absolutely necessary. All the other arguments can be included as \link[=RFoptions]{options}. \item \command{\link{RFgui}} is an instructive interface based on tcl/tk, replacing the former \code{ShowModels} } \item \bold{Inference for Gaussian random fields} \itemize{ \item \command{\link{RFfit}} has undergone a major revision. E.g.: (i) estimation of random effect models with spatial covariance structure (ii) automatic estimation of 10 and more arguments in multivariate and/or space-time models \item \command{\link{RFvariogram}} is now based on an fft algorithm if the data are on a grid, even allowing for missing values. \item \command{\link{RFratiotest}} has been added. } \item \bold{Processes} \itemize{ \item Modelling of \link[=maxstable]{maxstable processes} has been enhanced, including (i) the simulation of Brown-Resnick processes (ii) initial support of \link[=RMmodelsAdvanced]{tail correlation functions}; \item{Further processes} \link[=RPchi2]{chi2 processes}, \link[=RPpoisson]{compound Poisson processes}, \link[=RPbernoulli]{binary processes} added. } \item \bold{Models} \itemize{ \item the \link[=RFformula]{formula notation} for linear models may now be defined \item{Novel, user friendly definition of the covariance models} \item \link[=RMmodelsAdvanced]{Multivariate and vector-valued random fields} are now fully included \item The \link[=RMuser]{user} may now define his own functions, to some extend. \item The \link[=RMtrend]{trend} allows for much more flexibility \item \link[=RR]{Distributions} may now be included which will be extended to \link{Bayesian} modelling in future. } } } \me \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## S4 vs S3 x <- seq(0, 10, 0.1) model <- RMexp() plot(RFsimulate(model, x)) ## S4 plot(RFsimulate(model, x, spConform=FALSE)) ## no class \dontshow{FinalizeExample()}} RandomFields/man/RMschur.Rd0000644000176200001440000000274413437301604015256 0ustar liggesusers\name{RMschur} \alias{RMschur} \title{Schur product} \description{ The covariance function is \deqn{C(x)= M * \phi(x)} where \sQuote{*} denotes the Schur product, i.e. elementwise multiplication. } \usage{ RMschur(phi, M, diag, rhored, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}} \item{M}{constant \eqn{n \times n}{n x n} covariance matrix of the same size as multivariate model \code{phi}} \item{diag,rhored}{alternative way of passing \code{M}: \code{diag} is a vector of variances, \code{rhored} is a vector containing the correlations of the lower triangle of the \code{M}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMschur}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item ? } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMmatrix}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMschur(M=matrix(c(2, 1, 1, 1), ncol=2), RMparswm(nudiag=c(0.5, 2))) plot(model) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMmodelsTrend.Rd0000644000176200001440000000422513616114675016417 0ustar liggesusers\name{Trend Modelling} \alias{RMmodelsTrend} \alias{trend modelling} \title{Trend Modelling} \description{ The coding of trends, in particular multivariate trends, will be described here. } \details{ See \link{RFcalc}, \link{RMtrend} and also the examples below for some insight on the possibilities of trend modelling. } %\references{Ribeiro} \seealso{ \link{RFcalc}, \link{RM}, \link{RMmodels}, \link{RMtrend}, \link{RMmodelsMultivariate}. } \examples{\dontshow{StartExample();if (!interactive()) RFoptions(modus="careless")} %ok %RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set %## RFoptions(seed=NA) to make them all random again % require(geoR) # library(RandomFields) data(ca20) ## data set originally from geoR %ca20.df <- as.data.frame(ca20) head(ca20.df) RFoptions(coordnames=c("east", "north"), varnames="data") ## covariance model with variance, scale and nugget to be estimated; ## just to abbreviate later on M <- RMexp(var=NA, scale=NA) + RMnugget(var=NA) \dontshow{if (!interactive()) M <- RMexp(var=NA, scale=NA)} % ok ## short definition of a trend using the fact that ca20.df is a ## data.frame ca20.RFmod02 <- ~ 1 + altitude + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df, M=M)) ## long definition which also allows for more general constructions ca20.RFmod02 <- NA + NA*RMcovariate(ca20.df$altitude) + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ## Note that the following also works. ## Here, the covariance model must be the first summand ca20.RFmod02 <- M + NA + ca20.df$altitude print(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### The following does NOT work, as R assumes (NA + ca20.df$altitude) + M ### In particular, the model definition gives a warning, and the ### RFfit call gives an error: (ca20.RFmod02 <- NA + ca20.df$altitude + M) try(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### error ... ## factors: ca20.RFmod03 <- ~ 1 + area + M ### (ca20.fit03.RF <- RFfit(ca20.RFmod03, data=ca20.df, M=M)) \dontshow{FinalizeExample(); RFoptions(coordnames=NULL, varnames=NULL)} } \me \keyword{spatial} RandomFields/man/RMdampedcos.Rd0000644000176200001440000000426113437301604016065 0ustar liggesusers\name{RMdampedcos} \alias{RMdampedcos} \title{Exponentially Damped Cosine} \description{ \command{\link{RMdampedcos}} is a stationary isotropic covariance model. The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = exp(-\lambda r) \cos(r).}{C(r) = exp(-\lambda r) cos(r).} } \usage{ RMdampedcos(lambda, var, scale, Aniso, proj) } \arguments{ \item{lambda}{numeric. The range depends on the dimension of the random field (see details).} \item{var, scale, Aniso, proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{The model is valid for any dimension \eqn{d}{d}. However, depending on the dimension of the random field the following bound for the argument \eqn{\lambda}{\lambda} has to be respected: \deqn{\lambda \ge 1/{\tan(\pi/(2d))}.}{\lambda \ge 1/{tan(\pi/(2d))}.} This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92). For \eqn{\lambda = 0} we obtain the covariance function \deqn{C(r)=\cos(r)}{C(r)=cos(r)} which is only valid for \eqn{d=1}{d=1} and corresponds to \command{\link{RMbessel}} for \eqn{\nu=-0.5}{\nu=-0.5}, there. } \value{ \command{\link{RMdampedcos}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. \item Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) \emph{Handbook of Spatial Statistics.} Boca Raton: Chapman & Hall/CRL. } } \me \seealso{ \command{\link{RMbessel}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdampedcos(lambda=0.3, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMstrokorb.Rd0000644000176200001440000000462713437301604016001 0ustar liggesusers\name{Strokorb's Functions} \alias{RMstrokorb} \alias{RMm2r} \alias{RMm3b} \alias{RMmps} \title{Tail correlation function of the Brown-Resnick process} \description{ The models define various shape functions for max-stable processes for a given tail correlation function. } \usage{ RMm2r(phi) RMm3b(phi) RMmps(phi) } \arguments{ \item{phi}{a model for a tail correlation function belonging to the Gneiting class \eqn{H_d}} } \details{ \command{RMm2r} used with \command{\link{RPsmith}} defines a monotone shape function that corresponds to a tail correlation function belonging to Gneiting's class \eqn{H_d}. Currently, the function is implemented for dimensions 1 and 3. Called as such it returns the corresponding monotone function. \command{RMm3b} used with \command{\link{RPsmith}} defines balls with random \emph{radius} that corresponds to a tail correlation function belonging to Gneiting's class \eqn{H_d}. Currently, the function is implemented for dimensions 1 and 3. (Note that in Strokorb et al. (2014) the density function for twice the radius is considered.) Called as such it returns the corresponding density function for the radius of the balls. \command{RMmps} used with \command{\link{RPsmith}} defines random hyperplane polygons that correspond to a tail correlaton function belonging to Gneiting's class \eqn{H_d}. It currently only allows for \code{\link{RMbrownresnick}(\link{RMfbm}(alpha=1))} and dimension 2. Called as such it returns the tcf defined by the submodel -- this definition may change in future. } \value{ object of class \code{\link[=RMmodel-class]{RMmodel}} } \references{ \itemize{ \item Strokorb, K. (2013) \emph{Properties of the Extremal Coefficient Functions.} Univ. Goettingen. PhD thesis. \item Strokorb, K., Ballani, F. and Schlather, M. (2014) In Preparation. } } \seealso{ \command{\link{RFsimulate}}, \command{\link{RMmodel}}. } \me \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbrownresnick(RMfbm(alpha=1.5, s=0.2)) plot(RMm2r(model)) x <- seq(0, 10, 0.005) z <- RFsimulate(RPsmith(RMm2r(model), xi=0), x) plot(z, type="p", pch=20) \dontshow{FinalizeExample()}}RandomFields/man/RMtruncsupport.Rd0000644000176200001440000000260413437301604016715 0ustar liggesusers\name{RMtruncsupport} \alias{RMtruncsupport} \title{Truncating the Support of a Shape Function} \description{ \command{\link{RMtruncsupport}} may be used to truncate the support of a shape function when Poisson fields or M3 processes are created. } \usage{ RMtruncsupport(phi, radius) } \arguments{ \item{phi}{function of class \code{\link[=RMmodel-class]{RMmodel}}} \item{radius}{truncation at \code{radius}} } \value{ \command{\link{RMtruncsupport}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RMmatrix}}, \command{\link{RPpoisson}}. } \keyword{spatial} \keyword{models} \references{ \itemize{ \item Schlather, M. (2002) Models for stationary max-stable random fields. \emph{Extremes} \bold{5}, 33-44. } } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss() model1 <- RMtruncsupport(model, radius=1) plot(model) lines(model1, col="red") ## For a real application of 'RMtruncsupport' see example 2 of 'RPpoisson'. \dontshow{\dontrun{ model <- RPcoins(shape = RMtruncsupport(RMgauss(), radius=1.5), intensity=1) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x)) }} \dontshow{FinalizeExample()}}RandomFields/man/RMmodelsMultivariate.Rd0000644000176200001440000001102713437301604017776 0ustar liggesusers\name{RMmodelsMultivariate} \alias{RMmodelsMultivariate} \alias{Multivariate RMmodels} \title{Multivariate models} \description{ Here, multivariate and vector-valued covariance models are presented. } \details{ \bold{Bivariate covariance models} \tabular{ll}{ \command{\link{RMbicauchy}} \tab a bivariate Cauchy model\cr \command{\link{RMbiwm}} \tab full bivariate Whittle-Matern model (stationary and isotropic)\cr \command{\link{RMbigneiting}} \tab bivariate Gneiting model (stationary and isotropic)\cr \command{\link{RMbistable}} \tab a bivariate stable model\cr } \bold{Physically motivated, vector valued covariance and variogram models} \tabular{ll}{ \command{\link{RMcurlfree}} \tab curlfree (spatial) vector-valued field (stationary and anisotropic)\cr \command{\link{RMdivfree}} \tab divergence free (spatial) vector-valued field (stationary and anisotropic)\cr \command{\link{RMkolmogorov}} \tab Kolmogorov's model of turbulence\cr \command{\link{RMvector}} \tab vector-valued field (combining \command{\link{RMcurlfree}} and \command{\link{RMdivfree}}) } \bold{Multivariate covariance models} \tabular{ll}{ \command{\link{RMdelay}} \tab delay effect model (stationary)\cr \command{\link{RMderiv}} \tab field and its gradient\cr \command{\link{RMmatrix}} \tab linear model of coregionalization\cr \command{\link{RMparswm}} \tab multivariate Whittle-Matern model (stationary and isotropic)\cr } \bold{Operators} \tabular{ll}{ \command{\link{RMcov}} \tab covariance structure given by a multivariate variogram\cr \command{\link{RMexponential}} \tab functional returning \eqn{e^C}{exp(C)}\cr \command{\link{RMmatrix}} \tab linear model of coregionalization\cr \command{\link{RMmqam}} \tab multivariate quasi-arithmetic mean (stationary)\cr \command{\link{RMschur}} \tab element-wise product with a positive definite matrix\cr \command{\link{RMtbm}} \tab turning bands operator\cr } \bold{Trend models} \tabular{ll}{ \command{\link{RMtrend}} \tab for explicit trend modelling\cr \command{\link{R.models}} \tab for implicit trend modelling\cr \command{\link{R.c}} \tab binding univariate trend models into a vector\cr } } \references{ \itemize{ \item Chiles, J.-P. and Delfiner, P. (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York: Wiley. % \item Gneiting, T. and Schlather, M. (2004) % Statistical modeling with covariance functions. % \emph{In preparation.} \item Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., \emph{Space-Time Processes and Challenges Related to Environmental Problems.} New York: Springer. % \item Schlather, M. (2002) Models for stationary max-stable % random fields. \emph{Extremes} \bold{5}, 33-44. \item Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/} \item Wackernagel, H. (2003) \emph{Multivariate Geostatistics.} Berlin: Springer, 3rd edition. } } \seealso{\command{\link{RFformula}}, \command{\link{RMmodels}}, \command{\link{RM}}, \command{\link{RMmodelsAdvanced}} \sQuote{\href{../doc/multivariate_jss.pdf}{multivariate}}, a vignette for multivariate geostatistics } \me \keyword{spatial} \examples{\dontshow{StartExample()} % library(RandomFields) RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data dta <- RFsimulate(model = model, x=x, y=y, grid=FALSE) \dontshow{if (!interactive()) .dataorig <- dta} ## introducing some NAs ... dta@data$variable1[1:10] <- NA if (interactive()) dta@data$variable2[90:100] <- NA \dontshow{if (!interactive()) {print("no NAs introduced"); dta <- .dataorig}} plot(dta) % StartExample NICHT weiter vorne! ## co-kriging x <- y <- seq(0, 50, 1) \dontshow{if (!interactive()) x <- y <- seq(0, 5, 1)} k <- RFinterpolate(model, x=x, y=y, data= dta) plot(k, dta) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= dta) ## takes a while plot(z, dta) \dontshow{FinalizeExample()}} RandomFields/man/RPbernoulli.Rd0000644000176200001440000000360213437301604016122 0ustar liggesusers\name{RPbernoulli} \alias{RPbernoulli} \title{Simulation of Binary Random Fields} \description{ Indicator or binary field which has the value 1, if an underfield field exceeds a given threshold, 0 otherwise. } \usage{ RPbernoulli(phi, stationary_only, threshold) } \arguments{ \item{phi}{the \command{\link{RMmodel}}. Either a model for a process or a covariance model must be specified. In the latter case, a Gaussian process \command{\link{RPgauss}} is tacitely assumed.} \item{stationary_only}{optional arguments; same meaning as for \command{\link{RPgauss}}. It is ignored if the submodel is a process definition.} \item{threshold}{real valued. \command{\link{RPbernoulli}} returns \eqn{1} if value of the random field given by \code{phi} is equal to or larger than the value of \code{threshold}, and \eqn{0} otherwise. In the multivariate case, a vector might be given. If the threshold is not finite, then the original field is returned. \code{threshold} default value is 0. } } \value{ The function returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \details{ \command{\link{RPbernoulli}} can be applied to any field. If only a covariance model is given, a Gaussian field is simulated as underlying field. } \me \seealso{ \command{\link{Auxiliary RMmodels}}, \link{RP}, \command{\link{RMbernoulli}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RPbernoulli(RMexp(), threshold=0) z <- RFsimulate(model, x, x, n=4) plot(z) model <- RPbernoulli(RPbrownresnick(RMexp(), xi=1), threshold=1) z <- RFsimulate(model, x, x, n=4) plot(z) \dontshow{FinalizeExample()}} RandomFields/man/RMmastein.Rd0000644000176200001440000000650113437301604015565 0ustar liggesusers\name{RMmastein} \alias{RMmastein} \title{Ma-Stein operator} \description{ \command{\link{RMmastein}} is a univariate stationary covariance model depending on a variogram or covariance model on the real axis. The corresponding covariance function only depends on the difference \eqn{h}{h} between two points and is given by \deqn{C(h, t)=\frac{\Gamma(\nu + \phi(t))\Gamma(\nu + \delta)}{ \Gamma(\nu + \phi(t) + \delta) \Gamma(\nu)} W_{\nu + \phi(t)}(\|h -Vt\|)}{C(h, t)= [ Gamma(nu + phi(t))Gamma(nu + delta) ] / [Gamma(nu + phi(t) + delta) Gamma(nu) ] W_{nu + phi(t)}(|h - Vt|)} if \eqn{\phi} is a variogram model. It is given by \deqn{C(h, t)=\frac{\Gamma(\nu + \phi(0)-\phi(t))\Gamma(\nu + \delta)}{ \Gamma(\nu + \phi(0)-\phi(t) + \delta) \Gamma(\nu)} W_{\nu + \phi(t)}(\|h -Vt\|)}{C(h, t)= [ Gamma(nu + phi(0)-phi(t))Gamma(nu + delta) ] / [Gamma(nu + phi(0)-phi(t) + delta) Gamma(nu) ] W_{nu + phi(0)-phi(t)}(|h - Vt|)} if \eqn{\phi} is a covariance model. Here \eqn{\Gamma} is the Gamma function; \eqn{W} is the Whittle-Matern model (RMwhittle). } \usage{ RMmastein(phi, nu, delta, var, scale, Aniso, proj) } \arguments{ \item{phi}{an \command{\link{RMmodel}} on the real axis} \item{nu}{numerical value; positive; smoothness parameter of the Whittle-Matern model (for \eqn{t=0})} \item{delta}{a numerical value; \eqn{\delta} must be greater than or equal to half the dimension of \eqn{h}} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ See Stein (2005), formula (12). Instead of the velocity parameter \eqn{V} in the original model description, a preceding anisotropy matrix is chosen appropriately: \deqn{\left( \begin{array}{cc} A & -V \\ 0 & 1\end{array}\right)}{matrix(c(A, -V, 0, 1), nr=2, by=TRUE)} A is a spatial transformation matrix. (I.e. (x,t) is multiplied from the left on the above matrix and the first elements of the obtained vector are interpreted as new spatial components and only these components are used to form the argument in the Whittle-Matern function.) The last component in the new coordinates is the time which is passed to \eqn{\phi}{phi}. (Velocity is assumed to be zero in the new coordinates.) Note, that for numerical reasons, \eqn{\nu+\phi+d} may not exceed the value 80.0. If exceeded the algorithm fails. } \value{ \command{\link{RMmastein}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Ma, C. (2003) Spatio-temporal covariance functions generated by mixtures. \emph{Math. Geol.}, \bold{34}, 965-975. \item Stein, M.L. (2005) Space-time covariance functions. \emph{JASA}, \bold{100}, 310-321. } } \me \seealso{ \command{\link{RMwhittle}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make plotthem all random again model <- RMmastein(RMgauss(), nu=1, delta=10) plot(RMexp(), model.mastein=model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x)) \dontshow{FinalizeExample()}}RandomFields/man/RMbernoulli.Rd0000644000176200001440000000417613437301604016126 0ustar liggesusers\name{RMbernoulli} \alias{RMbernoulli} \title{Covariance Model for binary field based on a Gaussian field} \description{ \command{RMbernoulli} gives the centered \bold{correlation} function of a binary field, obtained by thresholding a Gaussian field. } \usage{ RMbernoulli(phi, threshold, correlation, centred, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}.} \item{threshold}{real valued threshold, see \command{\link{RPbernoulli}}. Currently, only \command{threshold=0.0} is possible. %to do Default: 0. } \item{correlation}{logical. If \code{FALSE} the corresponding covariance function is returned. Default: \code{TRUE}. } \item{centred}{logical. If \code{FALSE} the uncentred covariance is returned. Default: \code{TRUE}. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ This model yields the covariance function of the field that is returned by \command{\link{RPbernoulli}}. } \note{ \bold{Previous to version 3.0.33 the covariance function was returned, not the correlation function.} } \value{ \command{\link{RMbernoulli}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ Ballani, Schlather } \me \seealso{ \command{\link{RPbernoulli}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again threshold <- 0 x <- seq(0, 5, 0.02) GaussModel <- RMgneiting() n <- 1000 z <- RFsimulate(RPbernoulli(GaussModel, threshold=threshold), x=x, n=n) plot(z) model <- RMbernoulli(RMgauss(), threshold=threshold, correlation=FALSE) plot(model, xlim=c(0,5)) z1 <- as.matrix(z) estim.cov <- apply(z1, 1, function(x) cov(x, z1[1,])) points(coordinates(z), estim.cov, col="red") \dontshow{FinalizeExample()}}RandomFields/man/RPsmith.Rd0000644000176200001440000000657713437301604015271 0ustar liggesusers\name{Smith} \alias{RPsmith} \alias{mixed moving maxima} \alias{moving maxima} \alias{M2} \alias{M3} \title{(Mixed) Moving Maxima} \description{ \command{RPsmith} defines a moving maximum process or a mixed moving maximum process with finite number of shape functions. } \usage{ RPsmith(shape, tcf, xi, mu, s) } \arguments{ \item{shape}{an \command{\link{RMmodel}} giving the spectral function} \item{tcf}{an \command{\link{RMmodel}} specifying the extremal correlation function; either \code{shape} or \code{tcf} must be given. If \code{tcf} is given a shape function is tried to be constructed via the \command{\link{RMm2r}} construction of deterministic, monotone functions. } \item{xi,mu,s}{the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. } } \note{ IMPORTANT: For consistency reasons with the geostatistical definitions in this package the scale argument differs froms the original definition of the Smith model! See the example below. \command{RPsmith} depends on \command{\link{RRrectangular}} and its arguments. Advanced options are \code{maxpoints} and \code{max_gauss}, see \command{\link{RFoptions}}. } \details{ \GEV It simulates max-stable processes \eqn{Z} that are referred to as \dQuote{Smith model}. \deqn{Z(x) = \max_{i=1}^\infty X_i Y_i(x-W_i), }{Z(x) = max_{i=1, 2, ...} X_i * Y_i(x - W_i),} where \eqn{(W_i, X_i)} are the points of a Poisson point process on \eqn{\R^d \times (0, \infty)}{R^d x (0, \infty)} with intensity \eqn{dw * c/x^2 dx} and \eqn{Y_i \sim Y}{Y_i ~ Y} are iid measurable random functions with \eqn{E[\int \max(0, Y(x)) dx] < \infty}{E[int max(0, Y(x)) dx ] < \infty}. The constant \eqn{c} is chosen such that \eqn{Z} has standard Frechet margins. } \me \references{ \itemize{ \item Haan, L. (1984) A spectral representation for max-stable processes. \emph{Ann. Probab.}, \bold{12}, 1194-1204. \item Smith, R.L. (1990) Max-stable processes and spatial extremes Unpublished Manuscript. } } \seealso{ \command{\link{Advanced RMmodels}}, \command{\link{Auxiliary RMmodels}}, \command{\link{RMmodel}}, \command{\link{RPbernoulli}}, \command{\link{RPgauss}}, \link{maxstable}, \command{\link{maxstableAdvanced}}. } \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMball() x <- seq(0, 1000, 0.2) z <- RFsimulate(RPsmith(model, xi=0), x) plot(z) hist(z@data$variable1, 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## 2-dim x <- seq(0, 10, 0.1) z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) ## original Smith model x <- seq(0, 10, 0.05) model <- RMgauss(scale = sqrt(2)) # !! cf. definition of RMgauss z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) \dontshow{\dontrun{ ## original Smith model at arbitrary locations n <- 200 model <- RMgauss(scale = sqrt(2)) # !! cf. definition of RMgauss z <- RFsimulate(RPsmith(model, xi=0), runif(n, 0, 10), runif(0, 0, 10)) plot(z) }} ## for some more sophisticated models see 'maxstableAdvanced' \dontshow{FinalizeExample()}} RandomFields/man/RFformula.Rd0000644000176200001440000002152313437301604015564 0ustar liggesusers\name{RFformula} \alias{RFformula} \alias{RMformula} \title{RFformula - syntax to design random field models with trend or linear mixed models} \description{It is described how to create a formula, which, for example, can be used as an argument of \command{\link{RFsimulate}} and \command{\link{RFfit}} to simulate and to fit data according to the model described by the formula. In general, the created formula serves two purposes: \itemize{ \item to describe models in the \dQuote{Linear Mixed Models}-framework %including fixed and random effects \item to define models for random fields including trend surfaces from a geostatistical point of view. } Thereby, fixed effects and trend surfaces can be adressed via the expression \command{\link{RMfixed}} and the function \command{\link{RMtrend}}. In simple cases, the trend can also be given in a very simple, see the examples below. The covariance structures of the zero-mean multivariate normally distributed %random effects and random field components are adressed by objects of class \code{\link[=RMmodel-class]{RMmodel}}, which allow for a very flexible covariance specification. See \link{RFformulaAdvanced} for rather complicated model definitions. } \details{ The formula should be of the type \deqn{response ~ fixed effects %+ random effects + error term} or \deqn{response ~ trend + zero-mean random field + nugget effect,} respectively. Thereby: \itemize{ \item response\cr optional; name of response variable \item fixed effects/trend:\cr optional, should be a sum (using \command{\link[=RMplus]{+}})%%check link of components either of the form \code{X@RMfixed(beta)} or \code{\link{RMtrend}(...)} with \eqn{X} being a design matrix and \eqn{\beta} being a vector of coefficients (see \command{\link{RMfixed}} and \command{\link{RMtrend}}).\cr Note that a fixed effect of the form \eqn{X} is interpreted as \code{X@RMfixed(beta=NA)} by default (and \eqn{\beta} is estimated provided that the formula is used in \command{\link{RFfit}}). % \item random effects/zero-mean random field:\cr % optional, should be a sum (using \command{\link[=RMplus]{+}})%%check link % of components of the form \code{Z@model} % where \eqn{Z} is a design matrix and \code{model} is an object of %class \code{\link[=RMmodel-class]{RMmodel}}.\cr %\code{Z@model} describes a vector of random effects which is % normally distributed with zero mean and covariance matrix \eqn{Z % \Sigma Z^T} where \eqn{Z^T} is the transpose of \eqn{Z} and % \eqn{\Sigma} is the covariance matrix according to \code{model}.\cr % Note that a random effect/random fluctuation of the form % \code{model} is viewed as \code{I@model} where \eqn{I} is the % identity matrix of corresponding dimension. \item error term/nugget effect\cr optional, should be of the form \code{\link{RMnugget}(...)}. \command{\link{RMnugget}} describes a vector of iid Gaussian random variables. % Please note that the character \dQuote{@} in the RFformula-context can only % be used to multiply design-matrices with corresponding vectors of % fixed or random effects, whereas in the context of S4-classes \dQuote{@} is % used to access slots of corresponding objects. } } \section{IMPORTANT}{ Note that in formula constants are interpreted as part of a linear model, i.e. the corresponding parameter has to be estimated (e.g. \code{~ 1 + ...}) whereas in models not given as formula the parameters to be estimated must be given explicitly. } \note{ %to do: make the following point cleares (additional) argument names should always start with a capital letter. Small initial letters are reserved for \command{\link{RFoptions}}. } \references{ \itemize{ \item Chiles, J.-P. and P. Delfiner (1999) \emph{Geostatistics. Modeling Spatial Uncertainty.} New York, Chichester: John Wiley & Sons. \item McCulloch, C. E., Searle, S. R. and Neuhaus, J. M. (2008) \emph{Generalized, linear, and mixed models.} Hoboken, NJ: John Wiley & Sons. \item Ruppert, D. and Wand, M. P. and Carroll, R. J. (2003) \emph{Semiparametric regression.} Cambridge: Cambridge University Press. } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \code{\link[=RandomFields-package]{RandomFields}}.} \keyword{spatial} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") ############################################################## # # Example : Simulation and fitting of a two-dimensional # Gaussian random field with exponential covariance function # ############################################################### V <- 10 S <- 0.3 M <- 3 model <- RMexp(var=V, scale=S) + M x <- y <- seq(1, 3, 0.1) simulated <- RFsimulate(model = model, x=x, y=y) plot(simulated) # an alternative code to the above code: model <- ~ Mean + RMexp(var=Var, scale=Sc) simulated2 <- RFsimulate(model = model,x=x, y=y, Var=V, Sc=S, Mean=M) plot(simulated2) # a third way of specifying the model using the argument 'param' # the initials of the variables do not be captical letters model <- ~ M + RMexp(var=var, scale=sc) simulated3 <- RFsimulate(model = model,x=x, y=y, param=list(var=V, sc=S, M=M)) plot(simulated3) # Estimate parameters of underlying covariance function via # maximum likelihood model.na <- ~ NA + RMexp(var=NA, scale=NA) fitted <- RFfit(model=model.na, data=simulated) # compare sample mean of data with ML estimate, which is very similar: mean(simulated@data[,1]) fitted \dontshow{\dontrun{ ############################################################## # # Example 2: Fitting a standard linear mixed model using maximum # likelihood to estimate the variance components # ############################################################### # Y = W*beta + Z*u + e # where u ~ N(0, (sigma_u)^2 A) and e ~ N(0, (sigma_e)^2) W <- rep(1,times=10) Z <- matrix(rnorm(150) ,nrow=10, ncol=15) A <- RFcovmatrix(0:14, model=RMexp()) response <- W*5 + Z%*%matrix(1:225, nrow=15)%*%rnorm(15, sd=10) + rnorm(10, sd=3) # Estimate beta, (sigma_u)^2 and (sigma_e)^2: model <- response ~ W@RMfixed(beta=NA) + Z@RMfixcov(A, var=NA) + RMnugget(var=NA) fitted <- RFfit(model=model, data=response, W=W, Z=Z, A=A) }} \dontshow{\dontrun{ #### THIS EXAMPLE IS NOT PROGRAMMED YET ########################################################### # # Example 3: Simulate and fit a geostatistical model # ########################################################### # Simulate a Gaussian random field with trend m((x,y)) = 2 + 1.5 x - 3 y # with vector of coordinates (x,y) # and covariance function C(s,t) = 3*exp(-||(2*(s_1-t_1),s_2-t_2)||) + # 1.5*exp(-||(2*(s_1-t_1),s_2-t_2)||^2) # for s=(s_1,s_2) and t=(t_1,t_2) model <- ~ RMtrend(mean=2) + RMtrend(arbitraryfct=function(x) x, fctcoeff=1.5) + RMtrend(arbitraryfct=function(y) y, fctcoeff=-3) + RMplus(RMexp(var=3), RMgauss(var=1.5), Aniso=matrix(c(2,0,0,1),nrow=2)) simulated <- RFsimulate(model=model,x=seq(0,2,0.1),y=seq(-1,3,0.2)) # equivalent model model <- RMtrend(polydeg=1, polycoeff=c(2, 1.5, .3)) + RMplus(RMexp(var=3), RMgauss(var=1.5), Aniso=matrix(c(2,0,0,1), nrow=2)) simulated <- RFsimulate(model=model, x=seq(0,2,0.1), y=seq(-1,3,0.2)) # Estimate trend (polynomial of degree 1) and variance components such # that var_exp = 2*var_gauss as in the true model used for simulation model.na <- ~ RMtrend(polydeg=1) + RMplus(RMexp(var=2),RMgauss(var=2),var=NA, Aniso=matrix(c(NA,0,0,NA),nrow=2)) fit <- RFfit(model=model.na, data=simulated) }} \dontshow{\dontrun{ #### THIS EXAMPLE IS NOT PROGRAMMED YET #################################################################### # # Example 4: Simulate and fit a multivariate geostatistical model # #################################################################### # Simulate a bivariate Gaussian random field with trend # m_1((x,y)) = x + 2*y and m_2((x,y)) = 3*x + 4*y # where m_1 is a hyperplane describing the trend for the first response # variable and m_2 is the trend for the second one; # the covariance function is a multivariate nugget effect x <- y <- 0:10 model <- ~ RMtrend(plane=matrix(c(1,2,3,4), ncol=2)) + RMnugget(var=0.5, vdim=2) multi.simulated <- RFsimulate(model=model, x=x, y=y) # Fit the Gaussian random field with unknown trend for the second # response variable and unknown variances model.na <- ~ RMtrend(plane=matrix(c(NA,NA,NA,NA), ncol=2)) + RMnugget(var=NA, vdim=2) fit <- RFfit(model=model.na, data=multi.simulated) }} \dontshow{RFoptions(modus_operandi="normal")} \dontshow{FinalizeExample()}}RandomFields/man/RMgneiting.Rd0000644000176200001440000000636313437301604015737 0ustar liggesusers\name{RMgneiting} \alias{RMgneiting} \title{Gneiting Covariance Model} \description{ \command{\link{RMgneiting}} is a stationary isotropic covariance model which is only valid up to dimension 3, or 5 (see the argument \code{orig}). The corresponding covariance function only depends on the distance \eqn{r \ge 0}{r \ge 0} between two points and is given by \deqn{C(r) = (1 + 8 s r + 25 s^2 r^2 + 32 s^3 r^3)(1-s r)^8 }{C(r) = (1 + 8 s r + 25 s^2 r^2 + 32 s^3 r^3)(1-s r)^8 } if \eqn{0 \le r \le \frac{1}{s}}{0 <= r <= 1/s} and \deqn{C(r)=0}{C(r)=0} otherwise. Here, \eqn{s=0.301187465825}{s=0.301187465825}. For a generalized model see also \command{\link{RMgengneiting}}. } \usage{ RMgneiting(orig, var, scale, Aniso, proj) } \arguments{ \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} \item{orig}{logical. If \code{TRUE} the above model is used. Otherwise the \code{\link{RMgengneiting}} model C(s r) with \code{kappa=3} as above, but with \code{mu = 2.683509} and \code{s=0.2745640815} is used. The latter has the advantage of being closer to the Gaussian model and it is valid up to dimension 5. Default: \code{TRUE}. } } \details{ This isotropic covariance function is valid only for dimensions less than or equal to 3. It is 6 times differentiable and has compact support. This model is an alternative to \command{\link{RMgauss}} as its graph is hardly distinguishable from the graph of the Gaussian model, but possesses neither the mathematical nor the numerical disadvantages of the Gaussian model. It is a special case of \command{\link{RMgengneiting}} for the choice \eqn{\kappa=3, \mu=1.5}{\kappa=3, \mu=1.5}. Note that, in the original work by Gneiting (1999), a numerical value slightly deviating from the optimal one was used for \eqn{\mu=1.5}: \eqn{s=\frac{10 \sqrt(2)}{47}}{s=10 sqrt(2)/47}. } \value{ \command{\link{RMgneiting}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ For the original version \itemize{ \item Gneiting, T. (1999) Correlation functions for atmospherical data analysis. \emph{Q. J. Roy. Meteor. Soc} Part A \bold{125}, 2449-2464. } For the version (\code{orig=FALSE}) \itemize{ \item this package \pkg{RandomFields}. } } \me \seealso{ \command{\link{RMbigneiting}}, \command{\link{RMgengneiting}}, \command{\link{RMgauss}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(-3,3), maxchar=100) plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(1.5,2.5), maxchar=100) model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.2) ## nicer with 0.1 instead of 0.2 z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,4), maxGB=3) plot(z, MARGIN.slices=4, MARGIN.movie=3) \dontshow{FinalizeExample()}} RandomFields/man/RFloglikelihood.Rd0000644000176200001440000001042513437301604016743 0ustar liggesusers\name{RFloglikelihood} \alias{RFloglikelihood} \alias{RFlikelihood} \title{Likelihood and estimation of linear models} \description{ \command{\link{RFloglikelihood}} returns the log likelihood for Gaussian random fields. In case NAs are given that refer to linear modeling, the ML of the linear model is returned. } \usage{ RFlikelihood(model, x, y = NULL, z = NULL, T = NULL, grid = NULL, data, params, distances, dim, likelihood, estimate_variance =NA, ...) } \arguments{ \item{model,params}{\argModel} \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{data}{\argData} %\item{set}{integer. See section Value for details.} \item{likelihood}{ Not programmed yet. Character. Choice of kind of likelihood ("full", "composite", etc.), see also \code{likelihood} for \command{\link{RFfit}} in \command{\link{RFoptions}}. } %\item{log}{logical. If \code{TRUE} the loglikelihood is returned. % } \item{estimate_variance}{logical or \code{NA}. See Details. } \item{...}{\argDots} } \details{ The function calculates the likelihood for data of a Gaussian process with given covariance structure. The covariance structure may not have \code{NA} values in the parameters except for a global variance. In this case the variance is returned that maximizes the likelihood. Additional to the covariance structure the model may include a trend. The latter may contain unknown linear parameters. In this case again, the unknown parameters are estimated, and returned. } \value{ \command{\link{RFloglikelihood}} returns a list containing the likelihood, the log likelihood, and the global variance (if estimated -- see details). } \me \seealso{ \link{Bayesian}, \command{\link{RMmodel}}, \command{\link{RFfit}}, \command{\link{RFsimulate}}, \command{\link{RFlinearpart}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again requireNamespace("mvtnorm") pts <- 4 repet <- 3 model <- RMexp() x <- runif(n=pts, min=-1, max=1) y <- runif(n=pts, min=-1, max=1) dta <- as.matrix(RFsimulate(model, x=x, y=y, n=repet, spC = FALSE)) print(cbind(x, y, dta)) print(system.time(likeli <- RFlikelihood(model, x, y, data=dta))) str(likeli, digits=8) L <- 0 C <- RFcovmatrix(model, x, y) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=rep(0, nrow(dta)), sigma=C, log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) %-------------------------------------------------------------- pts <- 4 repet <- 1 trend <- 2 * sin(R.p(new="isotropic")) + 3 #trend <- RMtrend(mean=0) model <- 2 * RMexp() + trend x <- seq(0, pi, len=pts) dta <- as.matrix(RFsimulate(model, x=x, n=repet, spC = FALSE)) print(cbind(x, dta)) print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 tr <- RFfctn(trend, x=x, spC = FALSE) C <- RFcovmatrix(model, x) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=tr, sigma=C,log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) %-------------------------------------------------------------- pts <- c(3, 4) repet <- c(2, 3) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- 2 * RMexp() + trend x <- y <- dta <- list() for (i in 1:length(pts)) { x[[i]] <- list(x = runif(n=pts[i], min=-1, max=1), y = runif(n=pts[i], min=-1, max=1)) dta[[i]] <- as.matrix(RFsimulate(model, x=x[[i]]$x, y=x[[i]]$y, n=repet[i], spC = FALSE)) } print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 for (p in 1:length(pts)) { tr <- RFfctn(trend, x=x[[p]]$x, y=x[[p]]$y,spC = FALSE) C <- RFcovmatrix(model, x=x[[p]]$x, y=x[[p]]$y) for (i in 1:ncol(dta[[p]])) { print(system.time(dn <- mvtnorm::dmvnorm(dta[[p]][,i], mean=tr, sigma=C, log=TRUE))) L <- L + dn } } print(L) stopifnot(all.equal(likeli$log, L)) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMdivfree.Rd0000644000176200001440000000467413437301604015562 0ustar liggesusers\name{RMdivfree} \alias{RMdivfree} \title{Divfree Covariance Model} \description{ \command{\link{RMdivfree}} is a multivariate covariance model which depends on a univariate stationary covariance model where the covariance function phi(h) is twice differentiable. The corresponding matrix-valued covariance function C of the model only depends on the difference \eqn{h}{h} between two points and it is given by the following components: \itemize{ \item the potential \item the vector field given by \deqn{ C(h)=( - \Delta E + \nabla \nabla^T ) C_0(h) } \item the curl field } } \usage{ RMdivfree(phi, which, var, scale, Aniso, proj) } \arguments{ \item{phi}{a univariate stationary covariance model (in 2 or 3 dimensions).} \item{which}{vector of integers. If not given all components are returned; otherwise the selected components are returned. } \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \details{ The model returns the potential field in the first component, the corresponding divfree field and the field of curl strength in the last component. See also the models \command{\link{RMcurlfree}} and \command{\link{RMvector}}. } \value{ \command{\link{RMdivfree}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \references{ \itemize{ \item Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. \emph{Stochastic Models} \bold{28:3}. } } \me \seealso{ \command{\link{RMcurlfree}}, \command{\link{RMderiv}}, \command{\link{RMvector}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdivfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated) plot(simulated, select.variables=1) plot(simulated, select.variables=2:3) plot(simulated, select.variables=list(2:3)) plot(simulated, select.variables=list(1, 2:3, 4)) plot(simulated, select.variables=list(1, c(1, 2:3), 4)) \dontshow{FinalizeExample()}} RandomFields/man/papers.Rd0000644000176200001440000000425113437301604015160 0ustar liggesusers\name{papers} \alias{papers} %to do: check all \title{Papers involving \pkg{RandomFields} and co-authored by M. Schlather} \description{ Here, an overview is given over the papers co-authored by M. Schlather that involve \pkg{RandomFields}. } \me \references{ \itemize{ \item Gneiting, T., Kleiber, W. and Schlather, M. (2010) Matern cross-covariance functions for multivariate random fields \emph{J. Amer. Statist. Assoc.} \bold{105}, 1167-1177. See \link{GKS11} for the code. \item Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M., Jiang, Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in R2: Exploring the Limits. \emph{J. Comput. Graph. Stat.}, \bold{15}, 483-501. See \link{GSPSJ06} for the code. \item Scheuerer, M. and Schlather, M. (2012) Covariance Models for Random Vector Fields. \emph{Stochastic Models}, \bold{82}, 433-451. See \link{SS12} for the code. \item Schlather, M. (2002) Models for stationary max-stable random fields. \emph{Extremes} \bold{5}, 33-44. See \link{S02} for the code. \item Schlather, M. (2010) On some covariance models based on normal scale mixtures. \emph{Bernoulli}, \bold{16}, 780-797. See \link{S10} for the code. \item Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package \pkg{RandomFields}. \emph{ Journal of Statistical Software}, \bold{63} (8), 1-25, url = \sQuote{http://www.jstatsoft.org/v63/i08/}, See \sQuote{\href{../doc/multivariate_jss.pdf}{multivariate_jss}} for the vignette. \item Strokorb, K., Ballani, F. and Schlather, M. (2014) In Preparation. See \link{SBS14} for the code. } % Schlather, M. (2001) Simulation of stationary and isotropic random % fields. \emph{R-News} \bold{1} (2), 18-20. } \seealso{ \link{weather}, \link{GSPSJ06}, \link{SS12}, \link{S02}, \link{S10}, \link{jss14}. } \examples{\dontshow{StartExample()} # For examples, see the specific papers. \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMsign.Rd0000644000176200001440000000227113437301604015065 0ustar liggesusers\name{RMsign} \alias{RMsign} \alias{RRsign} \title{Random sign} \description{ \command{RMsign} defines a random sign. It can be used as part of the model definition of a Poisson field. } \usage{ RMsign(phi, p) } \arguments{ \item{phi}{shape function of class \code{\link[=RMmodel-class]{RMmodel}}} \item{p}{probability of keeping the sign} } \details{ \command{RMsign} changes the sign of the shape function \code{phi} with probability \code{1-p} and keeps it otherwise. } \value{ \command{\link{RMsign}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \note{ Random univariate or multivariate objects usually start with \code{RR}, not with \code{RM}. This is an exception here, as it operates on shape functions. } \me \seealso{ \command{\link{RMmodel}}, \link{RR}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPpoisson(RMsign(RMtent(), p=0.8)) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x)) \dontshow{FinalizeExample()}}RandomFields/man/RFfitOptimiser.Rd0000644000176200001440000000752713437301604016605 0ustar liggesusers\name{RFfitoptimiser} \alias{RFfitoptimiser} \alias{RFfitOptimiser} \title{Optimisers for fitting model parameters to spatial data } \description{ See \command{\link{RFfit}} for a detailed description of the fitting procedure. } \details{ Two parameters, see also \command{\link{RFoptions}} can be passed to \command{\link{RFfit}} that allow for choosing an optimiser different from \command{\link[stats]{optim}}: \code{optimiser} takes one of the values \code{"optim"}, \code{"optimx"}, \code{"soma"}, \code{"nloptr"}, \code{"GenSA"}, \code{"minqa"}, \code{"pso"} or \code{"DEoptim"}, see the corresponding packages for a description. If \code{optimiser="nloptr"}, then the additional parameter \code{algorithm} must be given which takes the values \code{"NLOPT_GN_DIRECT"}, \code{"NLOPT_GN_DIRECT_L"}, \code{"NLOPT_GN_DIRECT_L_RAND"}, \code{"NLOPT_GN_DIRECT_NOSCAL"}, \code{"NLOPT_GN_DIRECT_L_NOSCAL"}, \code{"NLOPT_GN_DIRECT_L_RAND_NOSCAL"}, \code{"NLOPT_GN_ORIG_DIRECT"}, \code{"NLOPT_GN_ORIG_DIRECT_L"}, \code{"NLOPT_LN_PRAXIS"}, \code{"NLOPT_GN_CRS2_LM"}, \code{"NLOPT_LN_COBYLA"}, \code{"NLOPT_LN_NELDERMEAD"}, \code{"NLOPT_LN_SBPLX"}, \code{"NLOPT_LN_BOBYQA"}, \code{"NLOPT_GN_ISRES"}, see \pkg{nloptr} for a description. } \me \seealso{ \command{\link{RFfit}}, \command{\link{RFoptions}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again \dontrun{ ## Here some alternative optimisers to 'optim' are considered. ## All but the \pkg{nloptr} algorithms are largely slower than 'optim'. ## Only a few of them return results as good as 'optim'. data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") All <- 1:7 rm(soil) data(soil) soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) \dontshow{if (RFoptions()$internal$examples_red){model<-~1+RMwhittle(scale=NA,var=NA,nu=1/2)}} ## standard optimiser 'optim' print(system.time(fit <- RFfit(model, data=dta))) print(fit) opt <- "optimx" # 30 sec; better result print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) \dontshow{\dontrun{ %in 6 sep 2017, soma has leak problems opt <- "soma" # 450 sec % sehr schlecht print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) }} opt <- "minqa" # 330 sec %ok print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "nloptr" algorithm <- RC_NLOPTR_NAMES \dontshow{if(!interactive()) algorithm <- RC_NLOPTR_NAMES[1]} for (i in 1:length(algorithm)) { % all algorithms are fast print(algorithm[i]) print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt, algorithm=algorithm[i])))) print(fit2) } if (interactive()) { ## the following two optimisers are too slow to be run on CRAN. opt <- "pso" # 600 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "GenSA" # 10^4 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) } } \dontshow{RFoptions(modus_operandi="normal")} \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{optimize} RandomFields/man/RFoptionsAdvanced.Rd0000644000176200001440000001034013437301604017233 0ustar liggesusers\name{RFoptionsAdvanced} \alias{RFoptionsAdvanced} \title{Setting control arguments of \pkg{RandomFields} -- advanced examples} \description{ Some more complex examples for the use of \command{\link{RFoptions}} are given. } \me \examples{\dontshow{StartExample()} %% NOTE: THE BELOW EXAMPLE NEEDS seed = NA ############################################################# ## EXAMPLE 1 ## ## The following gives an example on the advantage of ## ## dependent=TRUE for simulating with RPcirculant if, in a ## ## study, most of the time is spent with simulating the ## ## Gaussian random fields. Here, the covariance at a pair ## ## of points is estimated for n independent repetitions ## ## and 2*n locally dependent repetitions. ## ## To get the precision, the procedure is repeated m times.## ############################################################# # In the example below, local.dependent speeds up the simulation # by about factor 16 at the price of an increased variance of # factor 1.5 RFoptions(seed=NA) len <- 10 \dontshow{if(!interactive()){warning("reduced 'len'");len<-2;}}%ok x <- seq(0, 1, len=len) y <- seq(0, 1, len=len) grid.size <- c(length(x), length(y)) meth <- RPcirculant model <- RMexp(var=1.1, Aniso=matrix(nc=2, c(2,0.1,1.5,1))) m <- 5 n <- 100 \dontshow{if(!interactive()){warning("reduced 'm'");m<-2;}}%ok # using local.dependent=FALSE (which is the default) c1 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i, "out of", m, "\n") z <- RFsimulate(meth(model), x, y, n=n, pch="", dependent=FALSE, spConform=FALSE, trials=5, force=TRUE) c1[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) # many times slower than with local.dependent=TRUE below \dontshow{cat("\n")} true.cov <- RFcov(model, t(y[c(1, length(y))]), t(x[c(length(x), 1)])) print(time) Print(true.cov, mean(c1), sd(c1), empty.lines=1)## true mean is zero # using local.dependent=TRUE ... c2 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i) z <- RFsimulate(meth(model), x, y, n=2 * n, pch="", dependent=TRUE, spConform=FALSE, trials=5, force=TRUE) c2[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) \dontshow{cat("\n")} print(time) ## 20 times faster Print(true.cov, mean(c2), sd(c2), empty.lines=1) ## much better results ## the sd is smaller (using more locally dependent realisations) ## but it is (much) faster! Note that for n=n2 instead of n=2 * n, ## the value of sd(c2) would be larger due to the local dependencies ## in the realisations. ############################################################# ## EXAMPLE 2 ## ## This example shows that the same realisation can be ## ## obtained on different grid geometries (or point ## ## configurations, i.e. grid, non-grid) using TBM ## ############################################################# RFoptions(seed=0) step <- 1 x1 <- seq(-150,150,step) y1 <- seq(-15, 15, step) x2 <- seq(-50, 50, step) model <- RPtbm(RMexp(scale=10)) \dontshow{if(!interactive()){warning("values for x1, y1, x2 changed'");x1<-y1<-x2 <- -1:1}}%ok RFoptions(storing=TRUE) mar <- c(2.2, 2.2, 0.1, 0.1) points <- 700 ###### simulation of a random field on long thin stripe z1 <- RFsimulate(model, x1, y1, center=0, seed=0, points=points, storing=TRUE, spConform=FALSE) ScreenDevice(height=1.55, width=12) par(mar=mar) image(x1, y1, z1, col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) ###### definition of a random field on a square of shorter diagonal z2 <- RFsimulate(model, x2, x2, register=1, seed=0, center=0, points=points, spConform=FALSE) ScreenDevice(height=4.3, width=4.3) par(mar=mar) image(x2, x2, z2, zlim=range(z1), col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) tbm.points <- RFgetModelInfo(level=3)$loc$totpts Print(tbm.points, empty.lines=0) # number of points on the line \dontshow{FinalizeExample()}} RandomFields/man/QMath.Rd0000644000176200001440000002315113437301604014700 0ustar liggesusers% This file has been created automatically by 'rfGenerateMaths' \name{Mathematial C functions} \alias{R.models} \alias{RFcalc} \alias{math.c} \alias{R.} \alias{R.plus} %\alias{+} \alias{R.minus} \alias{-} \alias{R.mult} %\alias{*} \alias{R.div} \alias{/} \alias{R.const} \alias{R.c} \alias{c} \alias{R.is} \alias{R.p} \alias{R.lon} \alias{R.lat} \alias{R.gamma} \alias{gamma} \alias{R.acos} \alias{R.asin} \alias{asin} \alias{R.atan} \alias{atan} \alias{R.atan2} \alias{atan2} \alias{R.cos} \alias{cos} \alias{R.sin} \alias{sin} \alias{R.tan} \alias{tan} \alias{R.acosh} \alias{acosh} \alias{R.asinh} \alias{asinh} \alias{R.atanh} \alias{atanh} \alias{R.cosh} \alias{cosh} \alias{R.sinh} \alias{sinh} \alias{R.tanh} \alias{tanh} \alias{R.exp} \alias{exp} \alias{R.log} \alias{log} \alias{R.expm1} \alias{expm1} \alias{R.log1p} \alias{log1p} \alias{R.exp2} \alias{exp2} \alias{R.log2} \alias{log2} \alias{R.pow} \alias{^} \alias{R.sqrt} \alias{sqrt} \alias{R.hypot} \alias{hypot} \alias{R.cbrt} \alias{cbrt} \alias{R.ceil} \alias{ceiling} \alias{R.fabs} \alias{abs} \alias{R.floor} \alias{floor} \alias{R.fmod} \alias{\%\%} \alias{R.round} \alias{round} \alias{R.trunc} \alias{trunc} \alias{R.erf} \alias{erf} \alias{R.erfc} \alias{erfc} \alias{R.lgamma} \alias{lgamma} \alias{R.nextafter} \alias{R.nexttoward} \alias{R.remainder} \alias{R.ilogb} \alias{R.fdim} \alias{R.fmax} \alias{max} \alias{R.fmin} \alias{min} %\alias{R.nearbyint} %\alias{R.logb} %\alias{R.lrint} %\alias{R.llrint} %\alias{R.lround} %\alias{R.llround} %\alias{R.copysign} %\alias{R.tgamma} %\alias{R.rint} \alias{\%\%,ANY,RMmodel-method} \alias{\%\%,RMmodel,ANY-method} \alias{*,RMmodel,character-method} \alias{*,character,RMmodel-method} \alias{+,RMmodel,character-method} \alias{+,RMmodel,factor-method} \alias{+,RMmodel,list-method} \alias{+,character,RMmodel-method} \alias{+,data.frame,RMmodel-method} \alias{+,factor,RMmodel-method} \alias{-,RMmodel,character-method} \alias{-,character,RMmodel-method} \alias{/,RMmodel,character-method} \alias{/,character,RMmodel-method} \alias{^,ANY,RMmodel-method} \alias{^,RMmodel,ANY-method} \alias{^,RMmodel,character-method} \alias{^,character,RMmodel-method} \alias{abs,RMmodel-method} \alias{acosh,RMmodel-method} \alias{asin,RMmodel-method} \alias{asinh,RMmodel-method} \alias{atan2,ANY,RMmodel-method} \alias{atan2,RMmodel,ANY-method} \alias{atan,RMmodel-method} \alias{atanh,RMmodel-method} \alias{ceiling,RMmodel-method} \alias{cos,RMmodel-method} \alias{cosh,RMmodel-method} \alias{exp,RMmodel-method} \alias{expm1,RMmodel-method} \alias{floor,RMmodel-method} \alias{lgamma,RMmodel-method} \alias{log1p,RMmodel-method} \alias{log2,RMmodel-method} \alias{log,RMmodel-method} \alias{round,RMmodel,missing-method} \alias{sin,RMmodel-method} \alias{sinh,RMmodel-method} \alias{sqrt,RMmodel-method} \alias{tan,RMmodel-method} \alias{tanh,RMmodel-method} \alias{trunc,RMmodel-method} \title{Transformation of coordinate systems} \description{ The functions provide mathematical c functions as \link{RMmodels} } \usage{ RFcalc(model, params, ...) R.minus(x, y, factor) R.plus(x, y, factor) R.div(x, y, factor) R.mult(x, y, factor) R.const(x) R.c(a, b, c, d, e, f, g, h, i, j, l, m, n, o, p, q, ncol, factor) R.p(proj, new, factor) R.is(x, is, y) R.lon() R.lat() %c(...) R.gamma(x) R.acos(x) R.asin(x) R.atan(x) R.atan2(y, x) R.cos(x) R.sin(x) R.tan(x) R.acosh(x) R.asinh(x) R.atanh(x) R.cosh(x) R.sinh(x) R.tanh(x) R.exp(x) R.log(x) R.expm1(x) R.log1p(x) R.exp2(x) R.log2(x) R.pow(x, y) R.sqrt(x) R.hypot(x, y) R.cbrt(x) R.ceil(x) R.fabs(x) R.floor(x) R.fmod(x, y) R.round(x) R.trunc(x) R.erf(x) R.erfc(x) R.lgamma(x) R.remainder(x, y) R.fdim(x, y) R.fmax(x, y) R.fmin(x, y) \S4method{\%\%}{ANY,RMmodel}(e1,e2) \S4method{\%\%}{RMmodel,ANY}(e1,e2) \S4method{*}{RMmodel,character}(e1,e2) \S4method{*}{character,RMmodel}(e1,e2) \S4method{+}{RMmodel,character}(e1,e2) \S4method{+}{RMmodel,factor}(e1,e2) \S4method{+}{RMmodel,list}(e1,e2) \S4method{+}{character,RMmodel}(e1,e2) \S4method{+}{data.frame,RMmodel}(e1,e2) \S4method{+}{factor,RMmodel}(e1,e2) \S4method{-}{RMmodel,character}(e1,e2) \S4method{-}{character,RMmodel}(e1,e2) \S4method{/}{RMmodel,character}(e1,e2) \S4method{/}{character,RMmodel}(e1,e2) \S4method{^}{ANY,RMmodel}(e1,e2) \S4method{^}{RMmodel,ANY}(e1, e2) \S4method{^}{RMmodel,character}(e1,e2) \S4method{^}{character,RMmodel}(e1,e2) \S4method{abs}{RMmodel}(x) \S4method{acosh}{RMmodel}(x) \S4method{asin}{RMmodel}(x) \S4method{asinh}{RMmodel}(x) \S4method{atan2}{ANY,RMmodel}(y,x) \S4method{atan2}{RMmodel,ANY}(y,x) \S4method{atan}{RMmodel}(x) \S4method{atanh}{RMmodel}(x) \S4method{ceiling}{RMmodel}(x) \S4method{cos}{RMmodel}(x) \S4method{cosh}{RMmodel}(x) \S4method{exp}{RMmodel}(x) \S4method{expm1}{RMmodel}(x) \S4method{floor}{RMmodel}(x) \S4method{lgamma}{RMmodel}(x) \S4method{log1p}{RMmodel}(x) \S4method{log2}{RMmodel}(x) \S4method{log}{RMmodel}(x) \S4method{round}{RMmodel,missing}(x,digits) \S4method{sin}{RMmodel}(x) \S4method{sinh}{RMmodel}(x) \S4method{sqrt}{RMmodel}(x) \S4method{tan}{RMmodel}(x) \S4method{tanh}{RMmodel}(x) \S4method{trunc}{RMmodel}(x) } \arguments{ \item{model,params}{\argModel \code{model} is usually a \command{R.model} given here.} \item{e1,e2,x,y,a, b, c, d, e, f, g, h, i, j, l, m, n, o, p, q}{ constant or object of class \code{\link[=RMmodel-class]{RMmodel}}, in particular \command{R.model}} \item{ncol}{in contrast to \link[base]{c}, \command{R.c} also allows for defining matrices; \code{ncol} gives the number of columns} \item{factor}{constant factor multiplied with the function. This is useful when linear models are built} \item{is}{one of \code{"=="}, \code{"!="}, \code{"<="}, \code{"<"}, \code{">="}, \code{">"}} \item{proj}{selection of a component of the vector giving the location. Default value is 1.} \item{new}{\link{coordinate system} or other \code{\link[=RC_ISO_NAMES]{kind of isotropy}} which is supposed to be present at this model. It shold always be given if the coordinates are not cartesian. } \item{digits}{number of digits. Does not work with a \link{RMmodel}} \item{...}{\argDots} % \item{\code{signature(x = "RMmodel")}}{an \link{RMmodel}, especially a % function from this man page. } % \item{\code{signature(x = "ANY")}}{numeric or RMmodel } % \item{\code{signature(x = "character")}}{no characters allowed. } } \details{ \describe{ \item{R.plus}{adds two values} \item{R.minus}{substracts two values} \item{R.mult}{multiplies two values} \item{R.div}{devides two values} \item{R.const}{defines a constant } \item{R.c}{builds a vector} \item{R.is}{evaluates equalities and inequalities; note that \code{TRUE} is returned if the equality or inequality holds up to a tolerance given by \code{\link{RFoptions}()$nugget$tol}} \item{R.p}{takes a component out of the vector giving the location} \item{R.lon, R.lat}{longitudinal and latitudinal coordinate, given in the \emph{spherical system}, i.e. in radians. (earth system is in degrees).} \item{R.round}{Note that \command{R.round} rounds away from zero. } } For the remaining models see the corresponding C functions for their return value. (For any \sQuote{R.model} type \sQuote{man model} under Linux.) } \value{ Formally, the functions return an object of class \code{\link[=RMmodel-class]{RMmodel}}, except for \command{RFcalc} that returns a scalar. Neither vectors nor parentheses are allowed. } %\references{} \note{ Instead of \code{R.model} the standard function can be used in case there is no ambiguity, i.e., \code{c(...)},\code{asin(x)}, \code{atan(x)}, \code{atan2(y, x)}, \code{cos(x)}, \code{sin(x)}, \code{tan(x)}, \code{acosh(x)}, \code{asinh(x)}, \code{atanh(x)}, \code{cosh(x)}, \code{sinh(x)}, \code{tanh(x)}, \code{exp(x)}, \code{log(x)}, \code{expm1(x)}, \code{log2(x)}, \code{log1p(x)}, \code{exp2(x)}, \code{^}, \code{sqrt(x)}, \code{hypot(a,b)}, \code{cbrt(x)}, \code{ceiling(x)}, \code{abs(x)}, \code{floor(x)}, \code{round(x)}, \code{trunc(x)}, \code{erf(x)}, \code{ erfc(x)}, \code{lgamma(x)}. See the examples below. The function \command{RFcalc} is intended for simple calculations only and it is not excessively tested. Especially, binary operators should be used with caution. Note that all the functions here are NOT recognized as being positive definite (or negative definite), e.g. \command{cos} in \eqn{R^1}: \enumerate{ \item please use the functions given in \command{\link{RMmodels}} for definite functions (for \code{cos} see \command{\link{RMbessel}}) \item Using uncapsulated substraction to build up a covariance function is ambiguous, see the example in \command{\link{RMtrend}} } } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFfctn}}, \command{\link{RMtrend}} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## simple calculation RFcalc(3 + R.sin(pi/4)) ## calculation performed on a field RFfctn(R.p(1) + R.p(2), 1:3, 1:3) RFfctn(10 + R.p(2), 1:3, 1:3) ## calculate the distances between two vectors print(RFfctn(R.p(new="iso"), 1:10, 1:10)) ## simulation of a non-stationary field where ## anisotropy by a transform the coordinates (x_1^2, x_2^1.5) x <- seq(0.1, 6, 0.12) Aniso <- R.c(R.p(1)^2, R.p(2)^1.5) z <- RFsimulate(RMexp(Aniso=Aniso), x, x) ## calculating norms can be abbreviated: x <- seq(-5, 5, 5) #0.1) z2 <- RFsimulate(RMexp() + -40 + exp(0.5 * R.p(new="isotropic")), x, x) z1 <- RFsimulate(RMexp() + -40 + exp(0.5 * sqrt(R.p(1)^2 + R.p(2)^2)), x, x) stopifnot(all.equal(z1, z2)) plot(z1) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMdeclare.Rd0000644000176200001440000000550613437301604015530 0ustar liggesusers\name{RMdeclare} \alias{RMdeclare} \alias{RM_DECLARE} \title{Declaration of dummy variables for statistical inference} \description{ The only purpose of this function is the declaration of dummy variables for defining more complex relations between parameters that are to be estimated. Its value as a covariance model is identically zero, independently of the variables declared. } \usage{ RMdeclare(...) } \arguments{ \item{...}{ the names of additional parameters, not in inverted commas. No values should be given. } } %\details{} \note{ Only scalars can be defined here, since only scalars can be used within formulae. } \value{ \command{\link{RMdeclare}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}} } \author{Martin Schlather, \email{schlather@math.uni-mannheim.de} } \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## The following two examples illustrate the use of RMdeclare and the ## argument 'params'. The purpose is not to give nice statistical models x <- seq(1, 3, 0.1) %# geht nicht: model <- ~ 1+ RMexp(sc=sc1, var=var) + RMgauss(var=var2, %sc=sc2) + RMdeclare(v=5, u, z) ## note that there isn't any harm to declare variables ('u') ## RMdeclare that are of no use in a simulation model <- ~ RMexp(sc=sc1, var=var1) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) p <- list(sc1=2, var1=3, sc2=4, var2=5) z <- RFsimulate(model = model, x=x, y=x, params=p) plot(z) ## note that the model remains the same, only the values in the ## following list change. Here, sc1, var1, sc2 and u are estimated ## and var2 is given by a forula. p.fit <- list(sc1 = NA, var1=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper) print(f) ## The second example shows that rather complicated constructions are ## possible, i.e., formulae involving several variables, both known ('abc') ## and unknown ones ('sc', 'var'). Note that there are two different ## 'var's a unknown variable and an argument for RMwhittle \dontrun{%hier ein speicherfehler in Randomfieldsutils - falsch %erkanntes lin modell?? model2 <- ~ RMexp(sc) + RMwhittle(var = g, nu=Nu) + RMnugget(var=nugg) + RMexp(var=var, Aniso=matrix(A, nc=2)) + RMdeclare(CCC, DD) p.fit <- list(g=~sc^1.5, nugg=~sc * var * abc, sc=NA, var=~DD, Nu=NA, abc=123, A = ~c(1, 2, DD * CCC, CCC), CCC = NA, DD=NA) lower <- list(sc=1, CCC=1, DD=1) upper <- list(sc=100, CCC=100, DD=100) f2 <- RFfit(model2, data=z, params=p.fit, lower = lower, upper = upper) print(f2) } \dontshow{FinalizeExample()} }RandomFields/man/RMidmodel.Rd0000644000176200001440000000230613437301604015541 0ustar liggesusers\name{RMidmodel} \alias{RMidmodel} \title{Identical Model} \description{ \command{RMidmodel} is the identical operator on models, i.e. for objects of class \code{\link[=RMmodel-class]{RMmodel}}. } \usage{ RMidmodel(phi, vdim, var, scale, Aniso, proj) } \arguments{ \item{phi}{covariance function of class \code{\link[=RMmodel-class]{RMmodel}}} \item{vdim}{for internal purposes} \item{var,scale,Aniso,proj}{optional arguments; same meaning for any \command{\link{RMmodel}}. If not passed, the above covariance function remains unmodified.} } \value{ \command{\link{RMidmodel}} returns an object of class \code{\link[=RMmodel-class]{RMmodel}}. } \me \seealso{ \command{\link{RMmodel}}. \command{RMid}, \command{RMtrafo}, \command{RMprod} } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- 0:10 z <- RFsimulate(model, x) model2 <- RMidmodel(model) z2 <- RFsimulate(model, x) sum(abs(as.vector(z)- as.vector(z2))) == 0 # TRUE \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RFfctn.Rd0000644000176200001440000000227013437301604015047 0ustar liggesusers\name{RFfctn} \alias{RFfctn} \title{Evaluate Covariance and Variogram Functions} \description{ \command{\link{RFfctn}} returns the values of a shape function. } \usage{ RFfctn(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...) } \arguments{ \item{model,params}{\argModel } \item{x}{\argX} \item{y,z}{\argYz} \item{T}{\argT} \item{grid}{\argGrid} \item{distances,dim}{\argDistances} \item{...}{\argDots} } \details{ \command{\link{RFcovmatrix}} also allows for variogram models. Then the negative of the variogram matrix is returned. } \value{ \command{\link{RFfctn}} returns a vector. } \me \seealso{ \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}, \command{\link{RFcalc}}, \command{\link{RFcov}}, \command{\link{RFcovmatrix}}, \command{\link{RFpseudovariogram}}, \command{\link{RFvariogram}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() - 1 RFfctn(model, 1:10) \dontshow{FinalizeExample()}} \keyword{spatial} RandomFields/man/RMnonstwm.Rd0000644000176200001440000000304013437301604015625 0ustar liggesusers\name{RMnonstwm} \alias{RMnonstwm} \title{Non-stationary Whittle-Matern Covariance Model} \description{ The non-stationary Whittle-Matern model \eqn{C} is given by \deqn{C(x, y)=\Gamma(\mu) \Gamma(\nu(x))^{-1/2} \Gamma(\nu(y))^{-1/2} W_{\mu} (|x-y|)}{C(x, y)=\Gamma(\mu) \Gamma(\nu(x))^{-1/2} \Gamma(\nu(y))^{-1/2} W_{\mu} (|x-y|)} where \eqn{\mu = [\nu(x) + \nu(y)]/2}, and \eqn{\nu} must be a positive function. \eqn{W_{\mu}} is the covariance of the \command{\link{RMwhittle}} model or the \command{\link{RMmatern}} model. } \details{ The non-stationary Whittle-Matern models are obtained by the respective stationary model, replacing the real-valued argument for \code{nu} by a non-negative function. } \note{ It cannot be checked whether \code{nu} only takes positive values. So the responsibility is completely left to the user. } \references{ \itemize{ \item Stein, M. (2005) Nonstationary Spatial Covariance Functions. Tech. Rep., 2005 } } \me \seealso{ \command{\link{RMwhittle}}, \command{\link{RMmodel}}, \command{\link{RFsimulate}}, \command{\link{RFfit}}. } \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-1.2, 1.2, len=50) model <- RMwhittle(nu=RMgauss()) %plot(model, dim=2, xlim=c(-1,1)) z <- RFsimulate(model=model, x, x, n=4) plot(z) \dontshow{FinalizeExample()}} \keyword{spatial} \keyword{models} RandomFields/man/RMmodelsSphere.Rd0000644000176200001440000000730713437301604016564 0ustar liggesusers\name{Spherical models} \alias{RMmodelsSphere} \alias{sphere} \alias{spherical models} \alias{Spherical models} \alias{earth models} \alias{Earth models} \title{Covariance models valid on a sphere} \description{ This page summarizes the covariance models that can be used for spherical coordinates (and earth coordinates). } \details{ The following models are available: \bold{Completely monotone functions allowing for arbitrary scale} \tabular{ll}{ \command{\link{RMbcw}} \tab Model bridging stationary and intrinsically stationary processes for \eqn{\alpha \le 1} and \eqn{\beta < 0}\cr \command{\link{RMcubic}} \tab cubic model\cr \command{\link{RMdagum}} \tab Dagum model with \eqn{\beta < \gamma} and \eqn{\gamma \le 1}\cr \command{\link{RMexp}} \tab exponential model \cr \command{\link{RMgencauchy}} \tab generalized Cauchy family with \eqn{\alpha \le 1} (and arbitrary \eqn{\beta> 0})\cr \command{\link{RMmatern}} \tab Whittle-Matern model with \eqn{\nu \le 1/2}\cr %multiquadric todo %sine power todo \command{\link{RMstable}} \tab symmetric stable family or powered exponential model with \eqn{\alpha \le 1}\cr \command{\link{RMwhittle}} \tab Whittle-Matern model, alternative parametrization with \eqn{\nu \le 1/2}\cr } \bold{Other isotropic models with arbitrary scale} \tabular{ll}{ \command{\link{RMconstant}} \tab spatially constant model \cr \command{\link{RMnugget}} \tab nugget effect model \cr } \bold{Compactly supported covariance functions allowing for scales up to \eqn{\pi} (or \eqn{180} degrees)} \tabular{ll}{ \command{\link{RMaskey}} \tab Askey's model\cr \command{\link{RMcircular}} \tab circular model\cr \command{\link{RMgengneiting}} \tab Wendland-Gneiting model; differentiable models with compact support \cr \command{\link{RMgneiting}} \tab differentiable model with compact support \cr \command{\link{RMspheric}} \tab spherical model \cr } \bold{Anisotropic models} \tabular{ll}{ None up to now. } \bold{Basic Operators} \tabular{ll}{ \command{\link{RMmult}}, \code{*} \tab product of covariance models \cr \command{\link{RMplus}}, \code{+} \tab sum of covariance models or variograms\cr } \bold{See \link{RMmodels} for cartesian models.} } \me \seealso{ \link{coordinate systems}, \command{\link{RMmodels}}, \command{\link{RMtrafo}}. } \keyword{spatial} \keyword{models} \examples{\dontshow{StartExample()} RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(isotropy=c("spherical isotropic")) ## an example of a simple model valid on a sphere model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model) ## a simple simulation l <- seq(0, 85, 1.2) coord <- cbind(lon=l, lat=l) z <- RFsimulate(RMwhittle(s=30, nu=0.45), coord, grid=TRUE) # takes 1 min plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="orthographic", zenit=c(25, 25)) plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="gnomonic", zenit=c(25, 25)) plot(z) ## space-time modelling on the sphere sigma <- 5 * sqrt((R.lat()-30)^2 + (R.lon()-20)^2) model <- RMprod(sigma) * RMtrafo(RMexp(s=500, proj="space"), "cartesian") * RMspheric(proj="time") z <- RFsimulate(model, 0:10, 10:20, T=seq(0, 1, 0.1), coord_system="earth", new_coordunits="km") plot(z, MARGIN.slices=3) \dontshow{FinalizeExample(); }}RandomFields/DESCRIPTION0000644000176200001440000000415113616730065014337 0ustar liggesusersPackage: RandomFields Version: 3.3.8 Title: Simulation and Analysis of Random Fields Author: Martin Schlather [aut, cre], Alexander Malinowski [aut], Marco Oesting [aut], Daphne Boecker [aut], Kirstin Strokorb [aut], Sebastian Engelke [aut], Johannes Martini [aut], Felix Ballani [aut], Olga Moreva [aut], Jonas Auel[ctr], Peter Menck [ctr], Sebastian Gross [ctr], Ulrike Ober [ctb], Paulo Ribeiro [ctb], Brian D. Ripley [ctb], Richard Singleton [ctb], Ben Pfaff [ctb], R Core Team [ctb] Maintainer: Martin Schlather LinkingTo: RandomFieldsUtils Depends: R (>= 3.5.0), sp, RandomFieldsUtils (>= 0.5.1) Imports: graphics, methods, grDevices, stats, utils Suggests: colorspace, RColorBrewer, mvtnorm, raster, tcltk2, tcltk, tkrplot, spam, tools, minqa, soma, optimx, nloptr, pso, GenSA Description: Methods for the inference on and the simulation of Gaussian fields are provided, as well as methods for the simulation of extreme value random fields. Main geostatistical parts are based on the books by Christian Lantuejoul , Jean-Paul Chiles and Pierre Delfiner and Noel A. Cressie . For the extreme value random fields see Oesting, Schlather, Schillings (2019) and Schlather (2002) . Collate: aaa_auto.R aaa_globals.R basic.fctns.R bigdata.R Class.R convert_new.R convert.R Crossvalidation.R datasets.R D.H.R fitbernoulli.R fitbr.R fitgauss.R fitmaxstable.R fitpoisson.R getNset.R helmholz.R internal_use.R kriging.R Likelihoodratio.R Methods-aux.R Methods-RFsp.R obsolete.R RFempvario-Methods-plots.R RFempvario.R RFfit.R RFgui.R rf-plots.R rf.R RMmodels-Methods-plots.R RMmodelsBasics.R RMmodels.R RMmodelsConvenience.R RMmodelsSpecial.R RQmodels.R generatemodels.R zzz.R License: GPL (>= 3) URL: http://ms.math.uni-mannheim.de/de/publications/software/randomfields Packaged: 2020-02-03 22:08:36 UTC; schlather NeedsCompilation: yes Repository: CRAN Date/Publication: 2020-02-06 06:20:37 UTC RandomFields/configure.ac0000644000176200001440000000064013437301604015110 0ustar liggesusersAC_INIT([RandomFields], 3.3.4) if test "${CXX}" = gcc || "${CXX}" = clang; then dnl RANDOMFIELD_CXXFLAGS="-mavx" RANDOMFIELDS_CXXFLAGS="" dnl AC_MSG_RESULT([${OBJC} found, so that the package is compiled with 'avx']) else RANDOMFIELDS_CXXFLAGS="" AC_MSG_RESULT([Neither 'gcc' nor 'clang' found, so that AVX will not be used]) fi AC_SUBST(RANDOMFIELDS_CXXFLAGS) AC_CONFIG_FILES([src/Makevars]) AC_OUTPUT RandomFields/src/0000755000176200001440000000000013616114744013417 5ustar liggesusersRandomFields/src/shape.cc0000644000176200001440000010737413437301605015035 0ustar liggesusers/* Authors Martin Schlather, schlather@math.uni-mannheim.de Definition of correlation functions and derivatives (spectral measures, tbm operators) Note: * Never use the below functions directly, but only by the functions indicated in RFsimu.h, since there is no error check (e.g. initialization of RANDOM) * VARIANCE, SCALE are not used here * definitions for the random coin method can be found in MPPFcts.cc * definitions for genuinely anisotropic or nondomain models are in SophisticatedModel.cc; hyper models also in Hypermodel.cc Copyright (C) 2017 -- 2017 Martin Schlather This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "questions.h" #include "shape.h" #include "operator.h" #include "Coordinate_systems.h" /* Covariate models */ int cutidx(double Idx, int len) { int idx = (int) ROUND(Idx); if (idx < 0) idx = 0; if (idx >= len) idx = len - 1; return idx; } #define GET_LOC_COVARIATE \ assert(cov->Scovariate != NULL); \ location_type **local = P0INT(COVARIATE_RAW) || PisNULL(COVARIATE_X) \ ? PLoc(cov) : cov->Scovariate->loc; \ assert(local != NULL); \ location_type *loc = LocLoc(local); \ assert(loc != NULL) int get_index(double *x, model *cov) { GET_LOC_COVARIATE; // PMI(cov); // printf("%d %d to=%d last:%d==%d loc=%d\n",OWNTOTALXDIM, PREVTOTALXDIM, // total_logicaldim(SYSOF(cov)), PREVLASTSYSTEM, OWNLASTSYSTEM, // GetLoctsdim(cov)); double X[2]; int d, idx, i, nr = 0, cummul = 1.0, ntot = loc->totalpoints, dim = OWNTOTALXDIM; assert(OWNTOTALXDIM == PREVTOTALXDIM && PREVLASTSYSTEM == OWNLASTSYSTEM && OWNTOTALXDIM == total_logicaldim(SYSOF(cov)) && loc->timespacedim == OWNTOTALXDIM); //printf("grid = %d\n", loc->grid); if (loc->grid) { for (d = 0; dxgr[d][XLENGTH]; double step = loc->xgr[d][XSTEP]; if (d > 1 || !isAnySpherical(OWNISO(0))) { idx = cutidx((x[d] - loc->xgr[d][XSTART]) / step, len); } else { if (d == 0) { // to do: report technique? double full, half, y[2]; int idx2, xdim = 2; for (i=0; ixgr[i][XSTART]; if (isSpherical(OWNISO(0))) { full = M_2_PI; half = M_PI; if (GLOBAL.coords.polar_coord) NotProgrammedYet(""); } else if (isEarth(OWNISO(0))) { full = 360.0; half = 180.0; } else BUG; statmod2(y, full, half, X); idx = cutidx((x[0] - X[0]) / step, len); double X0 = X[0] + full * (2.0 * (double) (x[0] > X[0]) - 1); idx2 = cutidx((x[0] - X0) / step, len); if (FABS(x[0] - (X0 + idx2 * step)) < FABS(x[0] - (X[0] + idx * step))) idx = idx2; } else { assert(d==1); idx = cutidx((x[d] - X[1]) / step, len); } } nr += cummul * idx; // printf("nr = %d\n", nr); cummul *= len; } } else { // to do: effizienterer Zugriff ueber Kaestchen eines Gitters, // in dem die jeweiligen Punkte gesammelt werden. Dann muessen nur // 3^d Kaestchen durchsucht werden. model *next = cov->sub[0]; double distance, mindist = RF_INF, *given = loc->x; for (i=0; ichecked); NONSTATCOV(x, given, next, &distance); if (distance < mindist) { mindist = distance; nr = i; } } } return nr; } void kappa_covariate(int i, model VARIABLE_IS_NOT_USED *cov, int *nr, int *nc){ *nc = *nr = i <= COVARIATE_X || i == COVARIATE_FACTOR ? SIZE_NOT_DETERMINED : i <= COVARIATE_FACTOR ? 1 : -1; } void covariate(double *x, model *cov, double *v){ // ACHTUNG!! FALLS NAs verdeckt da sind, i.e. COVARIATE_ADDNA = TRUE: // HIER WIRD GETRICKST: vdim[0]=1 fuer Kovarianz, das hier nur // vim[0] abgefragt wird und de facto univariat ist // und vdim[1]=Anzahl der covariaten fuer matrix berechnung, da // fctnintern das produkt betrachtet und somit die dimensionen der // design matrix reflektiert. // Fuer COVARIATE_ADDNA = FALSE haben wir ganz normals Verhalten GET_LOC_COVARIATE; double *p = LP(COVARIATE_C); bool addna = (bool) cov->q[1]; assert(cov->vdim[!addna] == 1); int nr, dim = ANYDIM, vdim = cov->vdim[addna], ntot = loc->totalpoints; // PMI0(cov); if (hasAnyEvaluationFrame(cov)) { for (int i=0; i= LNROW(COVARIATE_C) * LNCOL(COVARIATE_C)) ERR("illegal access -- 'raw' should be FALSE"); } else { // interpolate: here nearest neighbour/voronoi nr = get_index(x, cov); // printf("x=%10g %10g: %d\n",x[0], x[1], nr); } // printf("%10g %10g %10g %d nr=%d q=%10g %d vdim=%d\n", x[0],x[1],x[2], dim, nr, cov->q[0], GLOBAL.general.vdim_close_together, vdim); if (cov->q[0] == 0) { if (GLOBAL.general.vdim_close_together) { p += nr * vdim; for (int i=0; icalling->calling); } } else { if (GLOBAL.general.vdim_close_together) { double dummy = 0.0; p += nr * vdim; for (int i=0; iScovariate != NULL && cov->Scovariate->matrix_err != MATRIX_NOT_CHECK_YET && cov->Scovariate->matrix_err != NOERROR) return cov->Scovariate->matrix_err; // #define RETURN assert(cov->calling != NULL); // globalXT && cov->calling != NULL && isnowTrend(cov) kdefault(cov, COVARIATE_RAW, globalXT //&& cov->calling != NULL && isnowTrend(cov) ); bool raw = P0INT(COVARIATE_RAW); if (raw) { model *calling = cov->calling; assert(calling != NULL); if (!globalXT || (// calling != NULL && isDollar(calling) && !hasVarOnly(calling) && calling->kappasub[DSCALE] != cov) ) { //printf("%d %d\n", isDollar(calling), !hasVarOnly(calling)); // APMI0(cov); SERR("if 'raw' then none of {'x', 'T', 'Aniso', 'proj', 'scale'} may be given"); } assert(cov->ownloc == NULL); if (cov->Scovariate == NULL) NEW_STORAGE(covariate); *local = PLoc(cov); } else { if ((ccs == cartesian && !equalsCartCoord(OWNISO(0))) || (ccs == earth && !equalsEarthCoord(OWNISO(0))) || (ccs == sphere && !equalsSphericalCoord(OWNISO(0)))) SERR2("'%.50s' not the global coordinate system ('%.50s')", ISO_NAMES[OWNISO(0)], COORD_SYS_NAMES[GLOBAL.coords.coord_system]); if (globalXT) { if (cov->Scovariate == NULL) NEW_STORAGE(covariate); *local = PLoc(cov); } else { // neither raw nor globalXT bool doset = cov->Scovariate == NULL; if (!doset) { location_type *loc = LocLoc(cov->Scovariate->loc); assert(loc != NULL); doset = Loc(cov)->spatialdim != loc->spatialdim || Loc(cov)->xdimOZ != loc->xdimOZ; } if (doset) { NEW_STORAGE(covariate); covariate_storage *S = cov->Scovariate; GLOBAL.general.set = store; S->loc = loc_set(PVEC(COVARIATE_X), false); GLOBAL.general.set = 0; assert(S->loc != NULL); if (S->loc[0]->timespacedim != OWNLOGDIM(0)) SERR1("number of columns of '%.50s' do not equal the dimension", KNAME(COVARIATE_X)); } *local = cov->Scovariate->loc; } // neither raw nor globalXT } ASSERT_ONESYSTEM; if (!raw) { if (cov->sub[0] == NULL) { addModel(cov, 0, TRAFO); kdefault(cov->sub[0], TRAFO_ISO, IsotropicOf(PREVISO(0))); } else { model *next = cov->sub[0]; PARAMINT(next, TRAFO_ISO)[0] = IsotropicOf(PREVISO(0)); } if ((err = CHECK(cov->sub[0], OWNLOGDIM(0), OWNXDIM(0), ShapeType, KERNEL, OWNISO(0), 1, cov->frame)) != NOERROR) { //APMI(cov); RETURN_ERR(err); } } RETURN_NOERROR; } int checkcovariate(model *cov){ assert(cov != NULL); int store = GLOBAL.general.set; GLOBAL.general.set = 0; int len, vdim = UNSET, err = NOERROR; location_type **local = NULL; // double value = 1.0; // covariate_storage *S; // bool addna = !PisNULL(COVARIATE_ADDNA) && P0INT(COVARIATE_ADDNA); bool addna; if (cov->q == NULL) { addna = (!PisNULL(COVARIATE_ADDNA) && P0INT(COVARIATE_ADDNA)) || (!PisNULL(COVARIATE_FACTOR) && ISNAN(P0(COVARIATE_FACTOR))); QALLOC(2); // cov->q[0] == 0 iff vdim vectors are returned cov->q[1] = addna; } else addna = (bool) cov->q[1]; if ((err = check_fix_covariate(cov, &local)) != NOERROR) goto ErrorHandling; assert(local != NULL); len = local[0]->len; //S = cov->Scovariate; assert(S != NULL); if (len <= 0) BUG; for (GLOBAL.general.set=0; GLOBAL.general.settotalpoints; if (GLOBAL.general.set == 0) { vdim = ndata/ntot; // PMI0(cov); //printf("vdim=%d %d %d\n", vdim, ndata, ntot); BUG; } //PMI(cov->calling); if (ntot <= 0) GERR("no locations given"); if (vdim * ntot != ndata) { //BUG; GERR3("Number of data (%d) not a multiple of\n'the number (%d) of locations times the number of components (%d)'.", ndata, ntot, vdim); } } assert(vdim > 0); if (addna) { if (!isnowTrend(cov)) GERR2("'%.50s' can be true only if '%.50s' is used as a trend", KNAME(COVARIATE_ADDNA), NAME(cov)); model *calling = cov->calling; if (PisNULL(COVARIATE_FACTOR)) { while (calling != NULL && CALLINGNR != LIKELIHOOD_CALL && CALLINGNR != LINEARPART_CALL) { calling = CALLINGNR == PLUS ? calling->calling : NULL; } } // if (calling == NULL) { // GERR1("%.50s is used with NAs outside a trend definition.", NAME(cov)); // } if (PisNULL(COVARIATE_FACTOR)) PALLOC(COVARIATE_FACTOR, vdim, 1); for (int i=0; iq[0] = ((bool) cov->q[1]) || PisNULL(COVARIATE_FACTOR) ? 0 : vdim; cov->vdim[!addna] = 1; cov->vdim[addna] = cov->q[0] == 0.0 ? vdim : 1; assert( VDIM0 > 0 && VDIM1 >0); if (hasAnyEvaluationFrame(cov) && VDIM0 != 1) GERR1("'%.50s' used in a wrong context", NICK(cov)); if ((err = checkkappas(cov, false)) != NOERROR) goto ErrorHandling; cov->mpp.maxheights[0] = RF_NA; ErrorHandling: GLOBAL.general.set = store; PFREE(COVARIATE_ADDNA); RETURN_ERR(err); } void rangecovariate(model *cov, range_type *range){ rangefix(cov, range); booleanRange(COVARIATE_ADDNA); range->min[COVARIATE_FACTOR] = RF_NEGINF; range->max[COVARIATE_FACTOR] = RF_INF; range->pmin[COVARIATE_FACTOR] = - 1e10; range->pmax[COVARIATE_FACTOR] = 1e10; range->openmin[COVARIATE_FACTOR] = true; range->openmax[COVARIATE_FACTOR] = true; } void kappa_fix(int i, model VARIABLE_IS_NOT_USED *cov, int *nr, int *nc){ *nc = *nr = i <= FIXCOV_X ? 0 : i <= FIXCOV_RAW ? 1 : -1; } void fix(double *x, double *y, model *cov, double *v){ GET_LOC_COVARIATE; int nrx, nry, dim = OWNTOTALXDIM, ntot = loc->totalpoints, vdim = VDIM0; double *p = LP(FIXCOV_M); assert(VDIM0 == VDIM1); if (P0INT(FIXCOV_RAW)) { // should happen only in a matrix context! nrx = (int) x[dim]; nry = y == NULL ? x[dim+1] : (int) y[dim]; if (nrx * vdim >= LNROW(FIXCOV_M) || nry * vdim >= LNCOL(FIXCOV_M)) ERR("illegal access -- 'raw' should be FALSE"); } else { nrx = get_index(x, cov); nry = get_index(y, cov); } int i, j, k, ntotvdim = ntot * vdim; if (GLOBAL.general.vdim_close_together) { p += (ntotvdim * nry + nrx) * vdim; for (k=i=0; idistances); fix(x, NULL, cov, v); } /* bool allowedDfix(model *cov) { kdefault(cov, FIXCOV_RAW, PisNULL(FIXCOV_X)); // && cov->calling != NULL && isnowTrend(cov)); if (P0INT(FIXCOV_RAW)) return allowedDtrue; for(int i=FIRST_DOMAIN; i<= LAST_DOMAINUSER; i++) cov->allowedD[i] = false; cov->allowedD[KERNEL] = true; return false; } */ bool allowedIfix(model *cov) { model *dummy = cov; location_type *loc = Loc(dummy); while (loc == NULL && dummy->calling != NULL) { dummy = dummy->calling; loc = Loc(dummy); } if (loc == NULL) BUG; bool dist = loc->distances, *I = cov->allowedI; //printf("name dummy = %.50s dist = %d\n", NAME(dummy), dist); kdefault(cov, FIXCOV_RAW, PisNULL(FIXCOV_X)); // && cov->calling != NULL && isnowTrend(cov)); for(int i=FIRST_ISOUSER; i<=LAST_ISOUSER; i++) I[i] = false; if (dist) I[ISOTROPIC] = I[EARTH_ISOTROPIC] = true; // not spherical since it involves a transformation that looses i_nrow else I[CARTESIAN_COORD] = I[EARTH_COORD] = true; return false; } /* bool setfix(model *cov) { kdefault(cov, FIXCOV_RAW, PisNULL(FIXCOV_X) && cov->calling != NULL && isnowTrend(cov)); if (P0INT(FIXCOV_RAW)) { isotropy_type iso = CONDPREVISO(0); if (!isFixed(iso)) return false; set_iso(OWN, 0, iso); set_dom(OWN, 0, PREVDOM(0)); } else { set_iso(OWN, 0, CoordinateSystemOf(PREVISO(0))); set_dom(OWN, 0, KERNEL); } return true; } */ Types Typefix(Types required, model *cov, isotropy_type requ_iso){ if (isBad(TypeConsistency(required, OWNTYPE(0)))) return BadType; if (P0INT(FIXCOV_RAW)) return required; return equalsCartCoord(requ_iso) ? required : BadType; } int checkfix(model *cov){ assert(cov != NULL); int store = GLOBAL.general.set; GLOBAL.general.set = 0; int vdim = UNSET, vdimSq = UNSET, err = NOERROR; location_type **local = NULL; bool isAnyIso = isAnyIsotropic(OWNISO(0)); assert(!isAnyIso || Loc(cov)->distances); if ((err = check_fix_covariate(cov, &local)) != NOERROR) goto ErrorHandling; if (!P0INT(FIXCOV_RAW)) { if (isAnyIso) SERR1("distances only allowed for '%.50s' = TRUE", KNAME(FIXCOV_RAW)); if (!(equalsKernel(OWNDOM(0)) && equalsCartCoord(OWNISO(0)))) SERR2("Model only allowed within positive definite kernels, not within positive definite functions. (Got %.50s, %.50s.)", DOMAIN_NAMES[OWNDOM(0)], ISO_NAMES[OWNISO(0)]); } assert(local != NULL); covariate_storage *S; int len; len = local[0]->len; S = cov->Scovariate; assert(S != NULL); if (len <= 0) BUG; for (GLOBAL.general.set=0; GLOBAL.general.settotalpoints; if (GLOBAL.general.set == 0) { vdim = (int) SQRT((double) ndata / (double) (ntot * ntot)); vdimSq = vdim * vdim; } if (ntot <= 0) GERR("no locations given"); if (cov->nrow[FIXCOV_M] != cov->ncol[FIXCOV_M]) GERR("square matrix expected"); if (vdimSq * ntot * ntot != ndata) GERR3("number of data (%d) not a multiple of the number of locations (%d x %d)^2", ndata, ntot, vdim); } assert(vdim > 0); VDIM0 = VDIM1 = vdim; if ((err = checkkappas(cov)) != NOERROR) goto ErrorHandling; if (vdim == 1 && len == 1) { GLOBAL.general.set = 0; double *c = LP(FIXCOV_M); int i, ntot = LocLoc(local)->totalpoints; for (i=0; iptwise_definite = pt_zero; if (i 0.0) { cov->ptwise_definite = pt_posdef; for (i++; iptwise_definite = pt_indef; break; } } else { // < 0.0 cov->ptwise_definite = pt_negdef; for (i++; i 0.0) { cov->ptwise_definite = pt_indef; break; } } } } else cov->ptwise_definite = pt_unknown; // to do ?! alle Matrizen ueberpruefen... if (S->matrix_err == MATRIX_NOT_CHECK_YET) { S->matrix_err = NOERROR; for (GLOBAL.general.set=0; GLOBAL.general.setmatrix_err = err = ERROR_MATRIX_SQUARE; goto ErrorHandling; } for (k=0; kmatrix_err = err = ERROR_MATRIX_POSDEF; goto ErrorHandling; } } else { if (len==1) PRINTF("covariance matrix is large, hence not verified to be positive definite."); else PRINTF("covariance matrix of %d%.50s set is large, hence not verified to be positive definite.", GLOBAL.general.set + 1, TH(GLOBAL.general.set + 1)); } } if (err != NOERROR) goto ErrorHandling; } cov->matrix_indep_of_x = true; cov->mpp.maxheights[0] = RF_NA; ErrorHandling: GLOBAL.general.set = store; RETURN_ERR(err); } void rangefix(model VARIABLE_IS_NOT_USED *cov, range_type *range){ range->min[FIXCOV_M] = RF_NEGINF; range->max[FIXCOV_M] = RF_INF; range->pmin[FIXCOV_M] = - 1e10; range->pmax[FIXCOV_M] = 1e10; range->openmin[FIXCOV_M] = true; range->openmax[FIXCOV_M] = true; range->min[FIXCOV_X] = RF_NA; range->max[FIXCOV_X] = RF_NA; range->pmin[FIXCOV_X] = RF_NA; range->pmax[FIXCOV_X] = RF_NA; range->openmin[FIXCOV_X] = true; range->openmax[FIXCOV_X] = true; booleanRange(FIXCOV_RAW); } // ---------------------------------------------------------------------- // ball void ball(double *x, model VARIABLE_IS_NOT_USED *cov, double *v) { //APMI(cov); // isotropic function, expecting only distance; BALL_RADIUS=1.0 assert(*x >= 0); *v = (double) (*x <= BALL_RADIUS); } void Inverseball(double *x, model VARIABLE_IS_NOT_USED *cov, double *v){ // crash(); *v = *x > 1.0 ? 0.0 : BALL_RADIUS; } int struct_ball(model *cov, model **newmodel){ ASSERT_NEWMODEL_NOT_NULL; if (hasSmithFrame(cov)) { return addUnifModel(cov, BALL_RADIUS, newmodel); } else { ILLEGAL_FRAME; } RETURN_NOERROR; } int init_ball(model *cov, gen_storage VARIABLE_IS_NOT_USED *s) { // TREE0(cov); PMI0(cov); assert(s != NULL); if (hasAnyEvaluationFrame(cov)) RETURN_NOERROR; if (hasSmithFrame(cov) || hasAnyPoissonFrame(cov)) { cov->mpp.maxheights[0] = 1.0; if (cov->mpp.moments >= 1) { cov->mpp.mM[1] = cov->mpp.mMplus[1] = VolumeBall(OWNLOGDIM(0), BALL_RADIUS); int i; for (i=2; i<=cov->mpp.moments; i++) cov->mpp.mM[i] = cov->mpp.mMplus[i] = cov->mpp.mM[1]; } } else if (hasRandomFrame(cov)) { RETURN_NOERROR; } else ILLEGAL_FRAME; RETURN_NOERROR; } void do_ball(model VARIABLE_IS_NOT_USED *cov, gen_storage VARIABLE_IS_NOT_USED *s) { assert(s != NULL); } // ---------------------------------------------------------------------- // Poisson polygons double meanVolPolygon(int dim, double beta) { double kd = VolumeBall(dim, 1.0), kdM1 = VolumeBall(dim-1, 1.0); return intpow(dim * kd / (kdM1 * beta), dim) / kd; } void Polygon(double *x, model VARIABLE_IS_NOT_USED *cov, double *v) { polygon_storage *ps = cov->Spolygon; assert(ps != NULL); *v = (double) isInside(ps->P, x); } void Inversepolygon(double VARIABLE_IS_NOT_USED *x, model *cov, double *v){ polygon_storage *ps = cov->Spolygon; int d, dim = OWNLOGDIM(0); if (ps == NULL) { *v = RF_NA; return; } polygon *P = ps->P; if (P != NULL) { double max = 0.0; for (d=0; dbox0[d]); if (y > max) max = y; y = FABS(P->box1[d]); if (y > max) max = y; } } else { BUG; *v = POW(meanVolPolygon(dim, P0(POLYGON_BETA)) / VolumeBall(dim, 1.0), 1.0/dim); // to do kann man noch mit factoren multiplizieren, siehe // strokorb/schlather, max // um unabhaengigkeit von der Dimension zu erlangen } } void InversepolygonNonstat(double VARIABLE_IS_NOT_USED *v, model *cov, double *min, double *max){ polygon_storage *ps = cov->Spolygon; int d, dim = OWNLOGDIM(0); assert(ps != NULL); if (ps == NULL) { for (d=0; dP; if (P != NULL) { for (d=0; dbox0[d]; max[d] = P->box1[d]; } } else { // gibt aquivalenzradius eines "mittleres" Polygon zurueck BUG; double size = POW(meanVolPolygon(dim, P0(POLYGON_BETA)) / VolumeBall(dim, 1.0), 1.0/dim); // to do kann man noch mit factoren multiplizieren, siehe // strokorb/schlather, max-stabile Modelle mit gleichen tcf for (d=0; drandomkappa = true; RETURN_NOERROR; } void range_polygon(model VARIABLE_IS_NOT_USED *cov, range_type *range){ range->min[POLYGON_BETA] = 0; range->max[POLYGON_BETA] = RF_INF; range->pmin[POLYGON_BETA] = 1e-3; range->pmax[POLYGON_BETA] = 1e3; range->openmin[POLYGON_BETA] = true; range->openmax[POLYGON_BETA] = true; } int struct_polygon(model VARIABLE_IS_NOT_USED *cov, model VARIABLE_IS_NOT_USED **newmodel){ /* ASSERT_NEWMODEL_NOT_NULL; double beta = P0(POLYGON_BETA); if (hasAny ShapeFrame(cov)) { double dim = OWNLOGDIM(0), safety = P0(POLYGON_SAFETY), // to do : zhou approach ! equiv_cube_length = POW(beta, -1.0/dim); return addUnifModel(cov, // to do : zhou approach ! 0.5 * equiv_cube_length * safety, newmodel); } else if (hasRandomFrame(cov)) RETURN_NOERROR; else { ILLEGAL_FRAME; } */ BUG; RETURN_NOERROR; } polygon_storage *create_polygon() { polygon_storage *ps; if ((ps = (polygon_storage*) MALLOC(sizeof(polygon_storage))) == NULL) return NULL; if ((ps->P = (polygon*) MALLOC(sizeof(polygon))) == NULL) { FREE(ps); return NULL; } polygon_NULL(ps); return ps; } int init_polygon(model *cov, gen_storage VARIABLE_IS_NOT_USED *s) { int i, err, dim = OWNLOGDIM(0); double beta = P0(POLYGON_BETA), lambda = beta; // / VolumeBall(dim - 1, 1.0) * (dim * VolumeBall(dim, 1.0)); assert(s != NULL); if (cov->Spolygon == NULL) { if ((cov->Spolygon = create_polygon()) ==NULL) RETURN_ERR(ERRORMEMORYALLOCATION); } // nicht nur aber auch zur Probe struct polygon_storage *ps = cov->Spolygon; assert(ps != NULL && ps->P != NULL); if (!false) { freePolygon(ps->P); if ((err=rPoissonPolygon(ps->P, lambda, true)) != NOERROR) SERR1("poisson polygon cannot be simulated (error=%d)", err); } else { BUG; // valgrind memalloc loss ! + lange Laufzeiten ?! if ((err=rPoissonPolygon2(ps, lambda, true)) != NOERROR) SERR1("Poisson polygon cannot be simulated (error=%d)", err); } if (hasSmithFrame(cov)) { double c = meanVolPolygon(dim, beta); cov->mpp.maxheights[0] = 1.0; for (i=1; i<=cov->mpp.moments; i++) cov->mpp.mM[i] = cov->mpp.mMplus[i] = c; } else ILLEGAL_FRAME; RETURN_NOERROR; } // ---------------------------------------------------------------------- // #define RATIONAL_A 0 #define RATIONAL_a 1 void kappa_rational(int i, model *cov, int *nr, int *nc){ *nc = (i == RATIONAL_A) ? OWNLOGDIM(0) : 1; *nr = (i == RATIONAL_A) ? OWNLOGDIM(0) : (i==RATIONAL_a) ? 2 : -1; } void minmaxEigenrational(model *cov, double *mm) { double *a = P(RATIONAL_a); if (a[0] < a[1]) { mm[0] = a[0]; mm[1] = a[1]; } else { mm[0] = a[1]; mm[1] = a[0]; } } double maxEigenrational(model VARIABLE_IS_NOT_USED *cov, double VARIABLE_IS_NOT_USED *mm) { double *a = P(RATIONAL_a); return (a[0] > a[1]) ? a[0] : a[1]; } void rational(double *x, model *cov, double *v) { int i, k, j, dim = OWNLOGDIM(0); double nu, *A = P(RATIONAL_A), *a = P(RATIONAL_a); nu = 0.0; for (k=0, i=0; inrow[RATIONAL_a] == 1) { double dummy = P0(RATIONAL_a); PFREE(RATIONAL_a); PALLOC(RATIONAL_a, 2, 1); P(RATIONAL_a)[0] = dummy; P(RATIONAL_a)[1] = 0.0; } if ((err = checkkappas(cov)) != NOERROR) RETURN_ERR(err); cov->mpp.maxheights[0] = P(RATIONAL_a)[0] > P(RATIONAL_a)[1] ? P(RATIONAL_a)[0] : P(RATIONAL_a)[1]; RETURN_NOERROR; } void rangerational(model VARIABLE_IS_NOT_USED *cov, range_type* range){ range->min[RATIONAL_A] = RF_NEGINF; range->max[RATIONAL_A] = RF_INF; range->pmin[RATIONAL_A] = - 1e10; range->pmax[RATIONAL_A] = 1e10; range->openmin[RATIONAL_A] = true; range->openmax[RATIONAL_A] = true; range->min[RATIONAL_a] = 0.0; range->max[RATIONAL_a] = RF_INF; range->pmin[RATIONAL_a] = 0.0; range->pmax[RATIONAL_a] = 10; range->openmin[RATIONAL_a] = false; range->openmax[RATIONAL_a] = true; } // ---------------------------------------------------------------------- // // Sigma(x) = diag>0 + A'xx'A #define EAXXA_E 0 #define EAXXA_A 1 #define ETAXXA_ALPHA 2 void kappa_EAxxA(int i, model *cov, int *nr, int *nc){ *nc = (EAXXA_A == i) ? OWNLOGDIM(0) : 1; *nr = i < DefList[COVNR].kappas ? OWNLOGDIM(0) : -1; } void EAxxA(double *x, model *cov, double *v) { int d, k, j, dim = OWNLOGDIM(0); double xA[EaxxaMaxDim], *E = P(EAXXA_E), *A = P(EAXXA_A); for (k=0, d=0; d mm[1]) mm[1] = E[i]; } } int checkEAxxA(model *cov){ int err; if (OWNXDIM(0) > EaxxaMaxDim) SERR2("For technical reasons max. dimension for ave is %d. Got %d.", EaxxaMaxDim, OWNXDIM(0)); if ((err = checkkappas(cov)) != NOERROR) RETURN_ERR(err); VDIM0 = VDIM1 = OWNLOGDIM(0); cov->mpp.maxheights[0] = RF_NA; RETURN_NOERROR; } void rangeEAxxA(model VARIABLE_IS_NOT_USED *cov, range_type* range){ range->min[EAXXA_E] = 0.0; range->max[EAXXA_E] = RF_INF; range->pmin[EAXXA_E] = 0.0001; range->pmax[EAXXA_E] = 10; range->openmin[EAXXA_E] = true; range->openmax[EAXXA_E] = true; range->min[EAXXA_A] = RF_NEGINF; range->max[EAXXA_A] = RF_INF; range->pmin[EAXXA_A] = - 1e10; range->pmax[EAXXA_A] = 1e10; range->openmin[EAXXA_A] = true; range->openmax[EAXXA_A] = true; } // ---------------------------------------------------------------------- // // Sigma(x) = diag>0 + A'xx'A void kappa_EtAxxA(int i, model VARIABLE_IS_NOT_USED *cov, int *nr, int *nc){ int logicaldim = 3; *nc = (i == EAXXA_A) ? logicaldim : 1; *nr = (i == EAXXA_E || i==EAXXA_A) ? logicaldim : (i==ETAXXA_ALPHA) ? 1 : -1; } void EtAxxA(double *x, model *cov, double *v) { int d, k, j, dim = OWNLOGDIM(0), time = dim - 1; double xAR[EaxxaMaxDim], R[9], *E = P(EAXXA_E), *A = P(EAXXA_A), phi = P0(ETAXXA_ALPHA), c = cos(phi * x[time]), s = SIN(phi * x[time]); R[0] = R[4] = c; R[1] = s; R[3] = -s; R[2] = R[5] = R[6] = R[7] = 0.0; R[8] = 1.0; { double xA[EaxxaMaxDim]; for (k=0, d=0; d mm[1]) mm[1] = E[i]; } } int checkEtAxxA(model *cov){ int err; if (OWNXDIM(0) != 3) SERR("The space-time dimension must be 3."); VDIM0 = VDIM1 = OWNLOGDIM(0); if ((err = checkkappas(cov)) != NOERROR) RETURN_ERR(err); cov->mpp.maxheights[0] = RF_NA; RETURN_NOERROR; } void rangeEtAxxA(model VARIABLE_IS_NOT_USED *cov, range_type* range){ int i; for (i=0; i<=2; i++) { range->min[i] = RF_NEGINF; range->max[i] = RF_INF; range->pmin[i] = - 1e10; range->pmax[i] = 1e10; range->openmin[i] = true; range->openmax[i] = true; } range->min[EAXXA_E] = 0.0; range->max[EAXXA_E] = RF_INF; range->pmin[EAXXA_E] = 0.0001; range->pmax[EAXXA_E] = 10; range->openmin[EAXXA_E] = true; range->openmax[EAXXA_E] = true; } // ---------------------------------------------------------------------- // // Sigma(x) = diag>0 + A'xx'A #define ROTAT_PHI 0 // both rotat and Rotat #define ROTAT_SPEED 1 void kappa_rotat(int i, model *cov, int *nr, int *nc){ *nc = 1; *nr = i < DefList[COVNR].kappas ? 1 : -1; } void rotat(double *x, model *cov, double *v) { int dim = OWNLOGDIM(0), time = dim - 1; double speed = P0(ROTAT_SPEED), phi = P0(ROTAT_PHI), absx = SQRT(x[0] * x[0] + x[1] * x[1]); *v = (absx == 0.0) ? 0.0 : speed * (cos(phi * x[time]) * x[0] + SIN(phi * x[time]) * x[1]) / absx; } void minmaxEigenrotat(model VARIABLE_IS_NOT_USED *cov, double *mm) { mm[0] = - 1; mm[1] = 1; } int checkrotat(model *cov){ int err; if (OWNXDIM(0) != 3) SERR("The space-time dimension must be 3."); if ((err = checkkappas(cov)) != NOERROR) RETURN_ERR(err); cov->mpp.maxheights[0] = RF_NA; RETURN_NOERROR; } void rangerotat(model VARIABLE_IS_NOT_USED *cov, range_type* range){ int i; for (i=0; i<2; i++) { range->min[i] = RF_NEGINF; range->max[i] = RF_INF; range->pmin[i] = - 1e10; range->pmax[i] = 1e10; range->openmin[i] = true; range->openmax[i] = true; } } // Sigma(x) = diag>0 + A'xx'A #define ROTAT_PHI 0 // both rotat and Rotat #define ROTAT_SPEED 1 void kappa_Rotat(int i, model *cov, int *nr, int *nc){ *nc = 1; *nr = i < DefList[COVNR].kappas ? 1 : -1; } void Rotat(double *x, model *cov, double *v) { int d, k, j, dim = OWNLOGDIM(0), time = dim - 1; double phi = P0(ROTAT_PHI), c = cos(phi * x[time]), s = SIN(phi * x[time]), R[9]; assert(dim ==3); R[0] = R[4] = c; R[1] = s; R[3] = -s; R[2] = R[5] = R[6] = R[7] = 0.0; R[8] = 1.0; for (k=0, d=0; dmpp.maxheights[0] = RF_NA; RETURN_NOERROR; } void rangeRotat(model VARIABLE_IS_NOT_USED *cov, range_type* range){ range->min[ROTAT_PHI] = RF_NEGINF; range->max[ROTAT_PHI] = RF_INF; range->pmin[ROTAT_PHI] = - 1e10; range->pmax[ROTAT_PHI] = 1e10; range->openmin[ROTAT_PHI] = true; range->openmax[ROTAT_PHI] = true; } // ---------------------------------------------------------------------- // void truncsupport(double *x, model *cov, double *v){ // truncsupport erwartet dass vorher $ kommt, sofern skalenmischung model *next = cov->sub[0]; int xdimown = OWNTOTALXDIM; double dist, radius = P0(TRUNC_RADIUS); // default -1 if (xdimown > 1) { int i; dist = 0.0; for (i=0; i=0 && dist > radius) { *v=0.0; return; } FCTN(x, next, v); } int checktruncsupport(model *cov) { model *next=cov->sub[0]; int err; // dim = OWNLOGDIM(0); // taken[MAX DIM], ASSERT_UNREDUCED; ASSERT_ONESYSTEM; set_maxdim(OWN, 0, INFDIM); cov->monotone = isMonotone(next->monotone) ? MONOTONE : NOT_MONOTONE; if ((err = CHECK_PASSTF(next, ShapeType, SUBMODEL_DEP, cov->frame)) != NOERROR) { // print("error !!\n"); RETURN_ERR(err); } setbackward(cov, next); RETURN_NOERROR; } void truncsupportInverse(double VARIABLE_IS_NOT_USED *x, model *cov, double *v){ *v = P0(TRUNC_RADIUS); } void rangetruncsupport(model VARIABLE_IS_NOT_USED *cov, range_type *range) { range->min[TRUNC_RADIUS] = 0; // < 0 : unset range->max[TRUNC_RADIUS] = RF_INF; range->pmin[TRUNC_RADIUS] = 0.00001; range->pmax[TRUNC_RADIUS] = 100.0; range->openmin[TRUNC_RADIUS] = true; range->openmax[TRUNC_RADIUS] = true; } int struct_truncsupport(model *cov, model **newmodel) { int err; ASSERT_NEWMODEL_NOT_NULL; if (hasPoissonFrame(cov) || hasSmithFrame(cov)) { if ((err = addUnifModel(cov, P0(TRUNC_RADIUS), newmodel)) != NOERROR) RETURN_ERR(err); } else ILLEGAL_FRAME_STRUCT; RETURN_NOERROR; } int init_truncsupport(model *cov, gen_storage *s) { int i, err, vdim = VDIM0; assert(VDIM0 == VDIM1); if (hasSmithFrame(cov) || hasAnyPoissonFrame(cov)) { model *next = cov->sub[0]; // double // radius = P0(TRUNC_RADIUS); // default -1 if ((err = INIT(next, cov->mpp.moments, s)) != NOERROR) RETURN_ERR(err); // if (radius>=0 && radius < cov->mpp.refradius) cov->mpp.refradius = radius; // Eplus, M2 are assumed to be still precise !! for (i=0; impp.maxheights[i] = next->mpp.maxheights[i]; RETURN_NOERROR; } else ILLEGAL_FRAME; } void do_truncsupport(model *cov, gen_storage *s) { // mppinfotype *info = &(s->mppinfo); model *next = cov->sub[0]; int i, vdim = VDIM0; // double // radius = P0(TRUNC_RADIUS); // default -1 assert(VDIM0 == VDIM1); DO(next, s); for (i=0; impp.maxheights[i] = next->mpp.maxheights[i]; // if (radius>=0 && radius < info->radius) info->radius = radius; } RandomFields/src/QMath.cc0000644000176200001440000004142413437301605014740 0ustar liggesusers// This file has been created automatically by 'rfGenerateMaths' #include #include #include "questions.h" #include "primitive.others.h" #include "startGetNset.h" void MathACos(double *x, model *cov, double *v){ MATH_DEFAULT *v = ACOS(w[0]); } void MathASin(double *x, model *cov, double *v){ MATH_DEFAULT *v = ASIN(w[0]); } void MathATan(double *x, model *cov, double *v){ MATH_DEFAULT *v = ATAN(w[0]); } void MathAtan2(double *x, model *cov, double *v){ MATH_DEFAULT *v = ATAN2(w[0], w[1]); } void MathCos(double *x, model *cov, double *v){ MATH_DEFAULT *v = COS(w[0]); } void MathSin(double *x, model *cov, double *v){ MATH_DEFAULT *v = SIN(w[0]); } void MathTan(double *x, model *cov, double *v){ MATH_DEFAULT *v = TAN(w[0]); } void MathAcosh(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = acosh(w[0]); // ACOSH() #else *v = LOG(w[0] + SQRT(w[0] * w[0] - 1.0)); #endif } void MathAsinh(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = asinh(w[0]); // ASINH() // printf("%10g %10g\n", *v, LOG(w[0] + SQRT(w[0] * w[0] + 1.0))); #else *v = LOG(w[0] + SQRT(w[0] * w[0] + 1.0)); #endif } void MathAtanh(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = atanh(w[0]); // ATANH() #else *v = 0.5 * LOG( (1 + w[0]) / (1 - w[0]) ); #endif } void MathCosh(double *x, model *cov, double *v){ MATH_DEFAULT *v = COSH(w[0]); } void MathSinh(double *x, model *cov, double *v){ MATH_DEFAULT *v = SINH(w[0]); } void MathTanh(double *x, model *cov, double *v){ MATH_DEFAULT *v = TANH(w[0]); } void MathExp(double *x, model *cov, double *v){ MATH_DEFAULT *v = EXP(w[0]); } void MathLog(double *x, model *cov, double *v){ MATH_DEFAULT *v = LOG(w[0]); } void MathExpm1(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = expm1(w[0]); // EXPM1() #else *v = EXP(w[0]) - 1.0; #endif } void MathLog1p(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = log1p(w[0]); // LOG1P() #else *v = LOG(1.0 + w[0]); #endif } void MathLogb(double *x, model *cov, double *v){ MATH_DEFAULT *v = LOGB(w[0]); // printf("logb %10g\t%10g\n", *v, logb(w[0])); } void MathExp2(double *x, model *cov, double *v){ MATH_DEFAULT *v = EXP2(w[0]); // printf("e %10g\t%10g\n", *v, EXP2(w[0])); } void MathLog2(double *x, model *cov, double *v){ MATH_DEFAULT *v = LOG_BASE2(w[0]); // printf("e %10g\t%10g\n", *v, LOG_BASE2(w[0])); } void MathPow(double *x, model *cov, double *v){ MATH_DEFAULT *v = POW(w[0], w[1]); } void MathSqrt(double *x, model *cov, double *v){ MATH_DEFAULT *v = SQRT(w[0]); } void MathHypot(double *x, model *cov, double *v){ MATH_DEFAULT #if defined _GLIBCXX_CMATH *v = hypot(w[0], w[1]); #else *v = SQRT(w[0] * w[0] + w[1] * w[1]); #endif } void MathCbrt(double *x, model *cov, double *v){ MATH_DEFAULT *v = CBRT(w[0]); // printf("e %10g\t%10g\n", *v, CBRT(w[0])); } void MathCeil(double *x, model *cov, double *v){ MATH_DEFAULT *v = CEIL(w[0]); } void MathFABS(double *x, model *cov, double *v){ MATH_DEFAULT *v = FABS(w[0]); } void MathFloor(double *x, model *cov, double *v){ MATH_DEFAULT *v = FLOOR(w[0]); } void MathFmod(double *x, model *cov, double *v){ MATH_DEFAULT *v = FMOD(w[0], w[1]); //printf("e %10g\t%10g\n", *v, FMOD(w[0], w[1])); } void MathRound(double *x, model *cov, double *v){ MATH_DEFAULT *v = ROUND(w[0]); } void MathTrunc(double *x, model *cov, double *v){ MATH_DEFAULT *v = TRUNC(w[0]); } /* void Mathnearbyint(double *x, model *cov, double *v){ MATH_DEFAULT *v = std::nearbyint(w[0]); } void MathLrint(double *x, model *cov, double *v){ MATH_DEFAULT *v = std::lrint(w[0]); } void MathLlrint(double *x, model *cov, double *v){ MATH_DEFAULT *v = llrint(w[0]); } void MathLRound(double *x, model *cov, double *v){ MATH_DEFAULT *v = l ROUND(w[0]); } void MathLLRound(double *x, model *cov, double *v){ MATH_DEFAULT *v = ll ROUND(w[0]); } void MathCopysign(double *x, model *cov, double *v){ MATH_DEFAULT *v = copysign(w[0], w[1]); } void MathRint(double *x, model *cov, double *v){ MATH_DEFAULT *v = rint(w[0]); } void MathNextafter(double *x, model *cov, double *v){ MATH_DEFAULT *v = nextafter(w[0], w[1]); } void MathNexttoward(double *x, model *cov, double *v){ MATH_DEFAULT *v = nexttoward(w[0], w[1]); } */ void MathErf(double *x, model *cov, double *v){ MATH_DEFAULT *v = 1.0 - 2.0 * pnorm(w[0], 0.0, INVSQRTTWO, 0, 0); } void MathErfc(double *x, model *cov, double *v){ MATH_DEFAULT *v = 2.0 * pnorm(w[0], 0.0, INVSQRTTWO, 0, 0); } void MathGamma(double *x, model *cov, double *v){ MATH_DEFAULT *v = gammafn(w[0]); } void MathLgamma(double *x, model *cov, double *v){ MATH_DEFAULT *v = lgammafn(w[0]); } void MathRemainder(double *x, model *cov, double *v){ MATH_DEFAULT *v = REMAINDER(w[0], w[1]); // printf("e %10g\t%10g\t%10g\n", *v, REMAINDER(w[0], w[1]), fr ound(w[1], 0)); } void MathFdim(double *x, model *cov, double *v){ MATH_DEFAULT *v = FDIM(w[0], w[1]); // printf("e %10g\t%10g\n", *v, FDIM(w[0], w[1])); } void MathFmax(double *x, model *cov, double *v){ MATH_DEFAULT *v = FMAX(w[0], w[1]); } void MathFmin(double *x, model *cov, double *v){ MATH_DEFAULT *v = FMIN(w[0], w[1]); } bool allowedImaths(model *cov) { int z = 0, k = DefList[COVNR].kappas; model *sub[MAXSUB]; for (int i=0; ikappasub[i] != NULL) sub[z++] = cov->kappasub[i]; return allowedIsubs(cov, sub, z); } #define ADDCOV(X) \ addCov(X, NULL, NULL); \ AddVariant(TrendType, PREVMODEL_I); \ setDI(NULL, allowedImaths, NULL); void includeStandardMath() { int first = currentNrCov; IncludeModel(".asin", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("asin"); kappanames("x", REALSXP); ADDCOV(MathASin); IncludeModel(".atan", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("atan"); kappanames("x", REALSXP); ADDCOV(MathATan); IncludeModel(".atan2", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("atan2"); kappanames("y", REALSXP, "x", REALSXP); ADDCOV(MathAtan2); IncludeModel(".cos", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("cos"); kappanames("x", REALSXP); ADDCOV(MathCos); IncludeModel(".sin", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("sin"); kappanames("x", REALSXP); ADDCOV(MathSin); IncludeModel(".tan", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("tan"); kappanames("x", REALSXP); ADDCOV(MathTan); IncludeModel(".asinh", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("asinh"); kappanames("x", REALSXP); ADDCOV(MathAsinh); IncludeModel(".atanh", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("atanh"); kappanames("x", REALSXP); ADDCOV(MathAtanh); IncludeModel(".cosh", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("cosh"); kappanames("x", REALSXP); ADDCOV(MathCosh); IncludeModel(".sinh", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("sinh"); kappanames("x", REALSXP); ADDCOV(MathSinh); IncludeModel(".tanh", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("tanh"); kappanames("x", REALSXP); ADDCOV(MathTanh); IncludeModel(".log", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("log"); kappanames("x", REALSXP); ADDCOV(MathLog); IncludeModel(".expm1", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("expm1"); kappanames("x", REALSXP); ADDCOV(MathExpm1); IncludeModel(".log1p", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("log1p"); kappanames("x", REALSXP); ADDCOV(MathLog1p); /* IncludeModel(".logb", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, !false, // macht ein haufen Aerger SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("logb"); kappanames("x", REALSXP); ADDCOV(MathLogb); */ IncludeModel(".exp2", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("exp2"); kappanames("x", REALSXP); ADDCOV(MathExp2); IncludeModel(".log2", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("log2"); kappanames("x", REALSXP); ADDCOV(MathLog2); IncludeModel(".hypot", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("hypot"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathHypot); IncludeModel(".cbrt", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("cbrt"); kappanames("x", REALSXP); ADDCOV(MathCbrt); IncludeModel(".ceil", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("ceil"); kappanames("x", REALSXP); ADDCOV(MathCeil); IncludeModel(".floor", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("floor"); kappanames("x", REALSXP); ADDCOV(MathFloor); IncludeModel(".fmod", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("fmod"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathFmod); IncludeModel(".round", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("round"); kappanames("x", REALSXP); ADDCOV(MathRound); IncludeModel(".trunc", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("trunc"); kappanames("x", REALSXP); ADDCOV(MathTrunc); /* IncludeModel(".nearbyint", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, false, NOT_MONTONE); nickname("nearbyint"); kappanames("x", REALSXP); ADDCOV(MathNearbyint); IncludeModel(".lrint", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("lrint"); kappanames("x", REALSXP); ADDCOV(Mathlrint); IncludeModel(".llrint", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("llrint"); kappanames("x", REALSXP); ADDCOV(MathLlrint); IncludeModel(".lround", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("lround"); kappanames("x", REALSXP); ADDCOV(MathLRound); IncludeModel(".llround", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("llround"); kappanames("x", REALSXP); ADDCOV(MathLLRound); IncludeModel(".copysign", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, false, NOT_MONTONE); nickname("copysign"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathCopysign); IncludeModel(".rint", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, false, NOT_MONTONE); nickname("rint"); kappanames("x", REALSXP); ADDCOV(MathRint); IncludeModel(".nextafter", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, false, NOT_MONTONE); nickname("nextafter"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathNextafter); IncludeModel(".nexttoward", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, false, NOT_MONTONE); nickname("nexttoward"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathNexttoward); */ IncludeModel(".erfc", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("erfc"); kappanames("x", REALSXP); ADDCOV(MathErfc); IncludeModel(".lgamma", MathDefType, 0, 0, 1, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("lgamma"); kappanames("x", REALSXP); ADDCOV(MathLgamma); IncludeModel(".remainder", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("remainder"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathRemainder); IncludeModel(".fdim", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("fdim"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathFdim); IncludeModel(".fmax", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("fmax"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathFmax); IncludeModel(".fmin", MathDefType, 0, 0, 2, NULL, XONLY, PREVMODEL_I,checkMath,rangeMath, PREF_TREND, false, SCALAR, PREVMODEL_DEP, falsch, NOT_MONOTONE); nickname("fmin"); kappanames("x", REALSXP, "y", REALSXP); ADDCOV(MathFmin); //////////////////////////////////////////////////////////////////////// for (int nr=first; nr #include //#include #include "RF.h" // z coordinate run the fastest in values, x the slowest #define LOOP(DOIT) \ for(int row = 0; row < vdim; row++) { \ for(int col = row; col < vdim; col++) { \ int curbin = nbin * (vdim * row + col), \ other = (row - col) * nbinvdim, \ endfor = nbin + curbin; \ for(int i = curbin; i < endfor; i++) { \ int i_other = i + other; \ double n = res[i_other + nidx] = res[i + nidx]; \ DOIT; \ res[i_other + evidx] = res[i + evidx]; \ res[i_other + sdSqidx] = res[i + sdSqidx]; \ } \ } \ } void calculate_means(int method, int vdim, int nbin, int totaln, double *sumhead, double *sumtail, double *res) { int nbinvdim = nbin * (1.0 - vdim), nidx = totaln * EV_N, evidx = totaln * EV_EV, sdSqidx = totaln * EV_SDSQ; switch(method){ case(METHOD_PSEUDO): case(METHOD_VARIOGRAM): LOOP(res[i + sdSqidx] = 0.25 * ( res[i + sdSqidx] / (n - 1.0) - res[i + evidx] * res[i + evidx] / (n * (n - 1.0))); res[i + evidx] /= (2.0 * n) ); break; case(METHOD_COVARIANCE): LOOP(double m0 = sumhead[i] / n; double mh = sumtail[i] / n; // Reihenfolge!! res[i + sdSqidx] = (res[i + sdSqidx] / (n - 1) - res[i + evidx] * res[i + evidx] / (n * (n - 1))); res[i + evidx] = res[i + evidx] / n - m0 * mh ); break; case(METHOD_PSEUDOMADOGRAM): case(METHOD_MADOGRAM): LOOP(res[i + sdSqidx] = (res[i + sdSqidx] / (n - 1) - res[i + evidx] * res[i + evidx] / (n * (n - 1))); res[i + evidx] /= n; ); break; default: PRINTF("calculate_means:\n"); XERR(TOOLS_METHOD); } } SEXP empirical(SEXP X, SEXP Dim, SEXP Lx, SEXP Values, SEXP Repet, SEXP Grid, SEXP Bin, SEXP Nbin, // note that within the subsequent algorithm // the sd of the Efct ist correctly calculated: // instead for summing up Efct^2 in sd one should // sum up a^2 + b^2 ! // so finally only NAs are returned in this case // use emp SEXP Vdim, SEXP Method) /* x : matrix of coordinates, ### rows define points * dim : dimension, * lx : length of x, y, and z * values : (univariate) data for the points * repet : number of repetitions (the calculated emprical variogram will * be an overall average) * grid : (boolean) if true lx must be 3 [ x==c(start, end, step) ] * bin : specification of the bins * sequence is checked whether it is strictly isotone * nbin : number of bins. i.e. length(bin) - 1 * vdim : dimension of data * method : defined above */ { int dim = INTEGER(Dim)[0], lx = INTEGER(Lx)[0], repet = INTEGER(Repet)[0], grid = INTEGER(Grid)[0], nbin = INTEGER(Nbin)[0], vdim = INTEGER(Vdim)[0], method = INTEGER(Method)[0]; double *x = REAL(X), *values = REAL(Values), *bin = REAL(Bin), *res = NULL, *sumhead = NULL, *sumtail = NULL; int totaln = nbin * vdim * vdim, nidx = totaln * EV_N, evidx = totaln * EV_EV, sdSqidx = totaln * EV_SDSQ; int d, halfnbin, gridpoints[MAXVARIODIM], dimM1, low, cur, up, err = NOERROR; long segment, totalpointsrepetvdim, totalpointsvdim, totalpoints = NA_INTEGER; double * xx[MAXVARIODIM], // maxdist[MAXVARIODIM],// dd, * BinSq = NULL; SEXP Res; // res contains the variogram (etc), variance of the variogram, and n.bin (res gets returned to function) // first column is of res is the variogram (etc) // second column is the variance of the variogram (etc) // third column n.bin (number of data per bin) PROTECT(Res = allocMatrix(REALSXP, totaln, 3)); res = REAL(Res); for(int i=0; i < totaln * 3; res[i++] = 0); if ( dim > MAXVARIODIM || dim <= 0) {err = TOOLS_DIM; goto ErrorHandling; } if( vdim == 1) { // set cross to pseudo, if dimension is 1 if(method == METHOD_VARIOGRAM) method = METHOD_PSEUDO; if(method == METHOD_MADOGRAM) method = METHOD_PSEUDOMADOGRAM; } for (int i = segment = 0; i < dim; i++, segment += lx) xx[i] = &(x[segment]); if (xx[0]==NULL) {err=TOOLS_XERROR; goto ErrorHandling; } for (int i=0; i< nbin; i++) { if (bin[i] >= bin[i + 1]) {err = TOOLS_BIN_ERROR; goto ErrorHandling; } } dimM1 = dim - 1; halfnbin = nbin / 2; if ((BinSq = (double * ) MALLOC(sizeof(double) * (nbin + 1)))==NULL) { err = ERRORMEMORYALLOCATION; goto ErrorHandling; } if(method == METHOD_COVARIANCE) { if( (sumhead = (double *) CALLOC(totaln, sizeof(double))) == NULL) { err = ERRORMEMORYALLOCATION; goto ErrorHandling; } if( (sumtail = (double *) CALLOC(totaln, sizeof(double))) == NULL) { err = ERRORMEMORYALLOCATION; goto ErrorHandling; } } for (int i = 0; i <= nbin; i++){ BinSq[i] = bin[i] > 0 ? bin[i] * bin[i] : bin[i]; } //////////////////////////////////// GRID //////////////////////////////////// if (grid) { int d1, d2, head, tail; double p1[MAXVARIODIM], p2[MAXVARIODIM], distSq, dx[MAXVARIODIM]; long indextail[MAXVARIODIM], indexhead[MAXVARIODIM], segmentbase[MAXVARIODIM]; //SegmentbaseTwo[MAXVARIODIM], //SegmentbaseFour[MAXVARIODIM]; // does not work!! : //GetGridSize(x, y, z, dim, &(gridpoints[0]), &(gridpoints[1]), &(gridpoints[2])); // totalpoints = gridpoints[0] * gridpoints[1] * gridpoints[2]; // // instead : // dd = 0.0; totalpoints = 1; for (int i = 0; i <= dimM1; i++) { gridpoints[i] = (int) (xx[i][XLENGTH]); totalpoints *= gridpoints[i]; // maxdist[i] = (gridpoints[i] - 1) * xx[i][XSTEP]; // dd += maxdist[i] * maxdist[i]; } totalpointsvdim = totalpoints * vdim; for (int i = 0; i <= dimM1; i++) { dx[i] = xx[i][XSTEP] * 0.99999999; } totalpointsrepetvdim = totalpointsvdim * repet; segmentbase[0] = 1; // here x runs the fastest; // SegmentbaseTwo[0] = segmentbase[0] << 1; //SegmentbaseFour[0] = segmentbase[0] << 2 ; for (int i = 1; i <= dimM1; i++) { segmentbase[i] = segmentbase[i - 1] * gridpoints[i - 1]; // SegmentbaseTwo[i] = segmentbase[i] << 1; // SegmentbaseFour[i] = segmentbase[i] << 2; } for (int i = 0; i <= dimM1; i++) {indexhead[i] = 0; p1[i] = 0.0; } // loop through all pair of points, except (head, tail) for head=tail, // which is treated separately at the end, if necessary (not relevant for // variogram itself, but for function E and V) #define FOR(DO) \ for (head = 0; headBinSq[0]) && (distSq <= BinSq[nbin])) { \ /* search which bin distSq in */ \ low = 0; up = nbin; /* 21.2.01, * nbin - 1 */ \ cur = halfnbin; \ while (low!=up) { \ if (distSq> BinSq[cur]) {low = cur;} else {up = cur-1;} \ cur = (up + low + 1) / 2; \ } \ for(int row = 0; row < vdim; row++) { \ for(int col = row; col < vdim; col++) { \ for (segment = 0; segment= gridpoints[d2]) { \ indextail[d2] = 0; p2[d2] = 0; \ d2--; \ assert(d2 >= 0); \ indextail[d2]++; \ p2[d2] +=dx[d2]; \ } \ } \ head++; \ if (head= gridpoints[d1]) { \ indexhead[d1] = 0; \ p1[d1] = 0; \ d1--; \ assert(d1 >= 0); \ indexhead[d1]++; \ p1[d1] +=dx[d1]; \ } \ } \ } switch(method){ case(METHOD_PSEUDO): // pseudo variogram FOR(double x2 = values[head + totalpoints * row + segment] - values[tail + totalpoints * col + segment]; x2 *= x2); break; case(METHOD_VARIOGRAM): // cross variogram FOR(double x2 = (values[head + totalpoints * row + segment] -values[tail + totalpoints * row + segment]) * (values[head + totalpoints * col + segment]-values[tail + totalpoints * col + segment])); break; case(METHOD_COVARIANCE): FOR(double x2 = (values[head + totalpoints * row + segment] * values[tail + totalpoints * col + segment]); sumhead[curbin] += values[head + totalpoints * row + segment]; sumtail[curbin] += values[tail + totalpoints * col + segment]); break; case(METHOD_PSEUDOMADOGRAM): // pseudo madogram FOR(double x2 = FABS(values[head + totalpoints * row + segment] - values[tail + totalpoints * col + segment])); break; case(METHOD_MADOGRAM): // cross madogram FOR(double x2 = FABS(values[head + totalpoints * row + segment] -values[tail + totalpoints * row + segment]) * FABS(values[head + totalpoints * col + segment] -values[tail + totalpoints * col + segment]); x2 = SQRT(x2)); break; default: PRINTF("empirical:\n"); err = TOOLS_METHOD; goto ErrorHandling; } } else { //////////////////////////////////// ARBITRARY ///////////////////////////// totalpoints = lx; totalpointsvdim = totalpoints * vdim; totalpointsrepetvdim = totalpointsvdim * repet; #define FORARB(DO) \ for (int i = 0; iBinSq[0] && distSq<=BinSq[nbin]) { \ low = 0; \ up = nbin; \ cur = halfnbin; \ while (low!=up) { \ if (distSq> BinSq[cur]) low = cur; \ else up = cur - 1; /* ( * ; * ]*/ \ cur = (up + low + 1) / 2; \ } \ for(int row = 0; row < vdim; row++) { \ for(int col = row; col < vdim; col++) { \ for (segment = 0; segment=bin[i+1]) {err=TOOLS_BIN_ERROR; goto ErrorHandling;} } if(vdim == 1) { if(method == METHOD_VARIOGRAM) method = METHOD_PSEUDO; if(method == METHOD_MADOGRAM) method = METHOD_PSEUDOMADOGRAM; } if ((BinSq = (double *) MALLOC(sizeof(double)* (nbin + 1)))==NULL) { err=ERRORMEMORYALLOCATION; goto ErrorHandling; } if(method == METHOD_COVARIANCE) { if( (sumhead = (double *) CALLOC(totaln, sizeof(double))) == NULL) { err = ERRORMEMORYALLOCATION; goto ErrorHandling; } if( (sumtail = (double *) CALLOC(totaln, sizeof(double))) == NULL) { err = ERRORMEMORYALLOCATION; goto ErrorHandling; } } // res contains the variogram, sd and n.bin (res gets returned to function) // first column is of res is the variogram // second column is the sd^2 and the third n.bin (number of data per bin) //printf("total %d %d %d %d \n", nstepT, twoNphi, *nbin, Ntheta); for(i = 0; i < totaln * 3; res[i++] = 0); for (i=0; i<= nbin; i++){if (bin[i]>0) BinSq[i]=bin[i] * bin[i]; else BinSq[i]=bin[i]; } assert(NEARBY(atan2(-1.0, 0.0) + PIHALF) == 0.0); assert(atan2(0.0, 0.0) == 0.0); maxbinsquare = BinSq[nbin]; //////////////////////////////////// GRID //////////////////////////////////// if (grid) { int segmentbase[6]; long totalpoints = 1; segmentbase[0]=1; // here x runs the fastest; for (i=0; i<=3; i++) { step[i] = xx[i][XSTEP]; gridpoints[i] = (int) xx[i][XLENGTH]; totalpoints *= (gridpoints[i] > 0) ? gridpoints[i] : 1; maxi[i] = (int) (SQRT(maxbinsquare) / step[i] + 0.1); if (maxi[i] >= gridpoints[i]) maxi[i] = gridpoints[i] - 1; mini[i] = -maxi[i]; // if (maxi[i]==0) maxi[i] = 1; wrong 22.11.03 segmentbase[i+1] = segmentbase[i] * gridpoints[i]; } segmentbase[4] *= vdim; segmentbase[5] = segmentbase[4] * repet; //printf("\n"); //for(int i=totalpoints;i<2*totalpoints;i+=100){ // printf("%10g ", values[i]); //} //printf("\n"); // sementbase: [0] : 1, [1] : length(x), [2] : length(x) * l(y), // [3] : l(x) * l(y) * l(z), [4] : l(x) * l(y) * l(z) * l(T) // [5] : l(x) * l(y) * l(z) * l(T) * repet // define needed so there is no if needed before each calculation (grid) #define FORXT(DO) \ for (ix=mini[0]; ix <= maxi[0]; ix++) { \ delta[0] = ix * step[0]; \ if ((psq[0] = delta[0] * delta[0]) > maxbinsquare) continue; \ \ vec[0] = ix; \ if (ix>=0) { \ endX = gridpoints[0] - ix; \ startX = 0; \ } else { \ endX = gridpoints[0]; \ startX = -ix; \ } \ for (iy= mini[1]; iy <= maxi[1]; iy++) { \ delta[1] = iy * step[1]; \ if ((psq[1] = delta[1] * delta[1] + psq[0]) > maxbinsquare) continue; \ vec[1] = vec[0] + iy * segmentbase[1]; \ \ /* angles */ \ phidata = NEARBY(atan2(delta[1], delta[0]) - startphi); \ phidata = Mod(phidata, TWOPI); \ kphi = nbin * (int) (phidata * invsegphi); \ \ \ for (iz=mini[2]; iz <= maxi[2]; iz++) { \ delta[2] = iz * step[2]; \ if ((psq[2] = delta[2] * delta[2] + psq[1]) > maxbinsquare) continue;\ vec[2] = vec[1] + iz * segmentbase[2]; \ \ { \ low=0; up= nbin; /* */ cur= halfnbin; \ while(low!=up){ \ if (psq[2] > BinSq[cur]) {low=cur;} else {up=cur-1;}/*( . ; . ]*/\ cur=(up+low+1)/2; \ } \ } /* low*/ \ \ /* angles*/ \ thetadata = NEARBY(atan2(delta[2],SQRT(psq[1]))-starttheta); \ thetadata = Mod(thetadata, PI); \ ktheta = (int) (thetadata * invsegtheta); \ \ low += kphi + ktheta * twoNphiNbin; \ \ for (deltaT=0, it=low; deltaT<=nstepTstepT; \ deltaT+=stepT, it+=nbinNphiNtheta) { \ vec[3] = vec[2] + deltaT * segmentbase[3]; \ \ assert(startX>=0); \ for (x=startX; x=0) { \ endY = gridpoints[1] * segmentbase[1] - vec[1]; \ startY = x; \ } else { \ endY = gridpoints[1] * segmentbase[1]; \ startY = x - iy * segmentbase[1]; \ } \ assert(startY>=0); \ for (y=startY; y=0) { \ endZ = gridpoints[2] * segmentbase[2] - vec[2]; \ startZ = y; \ } else { \ endZ = gridpoints[2] * segmentbase[2]; \ startZ = y - iz * segmentbase[2]; \ } \ assert(startZ>=0); \ for (z=startZ; z=0); \ /* inserts calculation from switch below */ \ DO; \ res[curbin + evidx] += x2; \ res[curbin + sdSqidx] += x2 * x2; \ res[curbin + nidx]++; \ } \ } \ } /* repeat*/ \ } /* t */ \ } /* z */ \ } /* y */ \ } /* x */ \ } /* deltaT */ \ } /* iz */ \ } /* iy */ \ } /* ix */ // checks which method shoud be used (gets inserted above) switch(method) { case(METHOD_PSEUDO): // pseudo variogram FORXT(double x2 = values[rep + totalpoints * row] - values[rv + totalpoints * col]; x2 *= x2); break; case(METHOD_VARIOGRAM): // cross variogram FORXT(double x2 = (values[rep + totalpoints * row] - values[rv + totalpoints * row]) * (values[rep + totalpoints * col] - values[rv + totalpoints * col])); break; case(METHOD_COVARIANCE): FORXT(double x2 = (values[rep + totalpoints * row] * values[rv + totalpoints * col]); sumhead[curbin] += values[rep + totalpoints * row]; sumtail[curbin] += values[rv + totalpoints * col]); break; case(METHOD_PSEUDOMADOGRAM): // pseudo madogram FORXT(double x2 = FABS(values[rep + totalpoints * row] - values[rv + totalpoints * col])); break; case(METHOD_MADOGRAM): // cross madogram FORXT(double x2 = FABS(values[rep + totalpoints * row] - values[rv + totalpoints * row]) * FABS(values[rep + totalpoints * col] - values[rv + totalpoints * col]); x2 = SQRT(x2)); break; default: PRINTF("emvarioXT:\n"); err = TOOLS_METHOD; goto ErrorHandling; } } else { //////////////////////////////////// ARBITRARY ///////////////////////////// // rows : x, columns : T long totalpoints, totalpointsrepetvdim, totalpointsvdim, spatial, jj; spatial = lx; i = 3; step[i] = xx[i][XSTEP]; gridpoints[i] = (int) xx[i][XLENGTH]; totalpoints = spatial * gridpoints[i]; totalpointsvdim = totalpoints * vdim; totalpointsrepetvdim = totalpoints * repet; // define needed so there is no if needed before each calculation (arbitrary) #define FORARBXT(DO) \ for (i=0;iBinSq[0]) && (distSq<=BinSq[nbin])) { \ low=0; up=nbin; cur=halfnbin; \ while (low!=up) { \ if (distSq> BinSq[cur]) {low=cur;} else {up=cur-1;} /* ( * ; * ]*/ \ cur=(up+low+1)/2; \ } \ \ /* angles */ \ phidata = NEARBY(atan2(dx[1], dx[0]) - startphi); \ phidata = Mod(phidata, TWOPI); \ kphi = nbin * (int) (phidata * invsegphi); \ \ thetadata = NEARBY(atan2(dx[2], zylinderradius) - starttheta); \ thetadata = Mod(thetadata, PI); \ ktheta = (int) (thetadata * invsegtheta); \ \ low += kphi + twoNphiNbin * ktheta; \ assert(low>=0 && low #include "def.h" #include "RandomFields.h" #include "auxiliary2.h" #include #define none 0 static R_NativePrimitiveArgType one_int[] = { INTSXP }, intdouble[] = {INTSXP, REALSXP }, intintdouble[] = {INTSXP, INTSXP, REALSXP }, charint[] = { STRSXP, INTSXP}, inttwochar[] = {INTSXP, STRSXP, STRSXP }, two_int[] = { INTSXP, INTSXP }, three_int[] = { INTSXP, INTSXP, INTSXP}, attr_arg[] = { INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP }; // static R_NativeArgStyle argin[] = {R_ARG_IN}, // argout[] = {R_ARG_OUT}, // hostarg[] = {R_ARG_OUT, R_ARG_OUT}; #define CDEF(name, n, type) {#name, (DL_FUNC) &name, n, type} static const R_CMethodDef cMethods[] = { CDEF(GetAttr, 14, attr_arg), CDEF(GetModelName, 3, inttwochar), CDEF(GetModelNr, 2, charint), CDEF(GetCurrentNrOfModels, 1, one_int), CDEF(GetNrParameters, 2, two_int), CDEF(PrintModelList, 3, three_int), CDEF(PutValuesAtNA, 2, intdouble), CDEF(PutValuesAtNAnoInit, 2, intdouble), CDEF(expliciteDollarMLE, 2, intdouble), CDEF(MultiDimRange, 3, intintdouble), CDEF(GetModelRegister, 2, charint), CDEF(ResetWarnings, 1, one_int), CDEF(NoCurrentRegister, 0, none), CDEF(GetCurrentRegister, 1, one_int), CDEF(PutGlblVar, 2, intdouble), CDEF(attachRFoptionsRandomFields, 1, one_int), CDEF(detachRFoptionsRandomFields, 0, none), CDEF(RelaxUnknownRFoptions, 1, one_int), // CDEF(attachRFoptionsUtils, 0, NULL, NULL}, // CDEF(detachRFoptionsUtils, 0, NULL, NULL}, {NULL, NULL, 0, none} }; #define CALLDEF_DO(name, n) {#name, (DL_FUNC) &name, n} static R_CallMethodDef callMethods[] = { // in die respectiven C-Dateien muss RandomFieldsUtils.h eingebunden sein CALLDEF_DO(GetParameterNames, 1), CALLDEF_DO(GetSubNames, 1), CALLDEF_DO(GetAllModelNames, 1), CALLDEF_DO(GetCoordSystem, 3), CALLDEF_DO(GetModelInfo, 5), CALLDEF_DO(GetModel, 7), CALLDEF_DO(Init, 4), CALLDEF_DO(EvaluateModel, 2), // CALLDEF_DO(EvaluateModelXX, 0), CALLDEF_DO(GetProcessType, 2), CALLDEF_DO(empirical, 10), CALLDEF_DO(empvarioXT, 13), CALLDEF_DO(fftVario3D, 14), CALLDEF_DO(boxcounting, 5), CALLDEF_DO(detrendedfluc, 5), CALLDEF_DO(periodogram, 6), CALLDEF_DO(minmax, 5), CALLDEF_DO(VariogramIntern, 1), CALLDEF_DO(CovLoc, 6), CALLDEF_DO(GetNAPositions, 7), CALLDEF_DO(SetAndGetModelInfo, 10), CALLDEF_DO(SetAndGetModelLikelihood, 4), CALLDEF_DO(Take2ndAtNaOf1st, 8), CALLDEF_DO(countelements, 3), CALLDEF_DO(countneighbours, 6), CALLDEF_DO(getelements, 5), CALLDEF_DO(getneighbours, 5), CALLDEF_DO(set_boxcox, 1), CALLDEF_DO(get_boxcox, 0), // CALLDEF_DO(BoxCox_inverse, 2), CALLDEF_DO(BoxCox_trafo, 4), CALLDEF_DO(get_logli_residuals, 1), CALLDEF_DO(get_likeliinfo, 1), CALLDEF_DO(simple_residuals, 1), CALLDEF_DO(get_linearpart, 2), CALLDEF_DO(vectordist, 2), CALLDEF_DO(maintainers_machine, 0), // CALLDEF_DO(), {NULL, NULL, 0} }; // otherwise clang does not recognize it #ifdef __cplusplus extern "C" { #endif void R_init_RandomFields(DllInfo *dll) { R_registerRoutines(dll, cMethods, callMethods, NULL, // .Fortran NULL // extended ); R_useDynamicSymbols(dll, FALSE); // OK } void R_unload_RandomFields(DllInfo *info) { // just to avoid warning from compiler //int *x = (int*) info; x = x + 0; // if (0) { PRINTF("%ld\n", (long int) info);} /* Release resources. */ } #ifdef __cplusplus } #endif RandomFields/src/PoissonPolygon.h0000644000176200001440000000370013437301605016565 0ustar liggesusers /* Authors Martin Schlather, schlather@math.uni-mannheim.de Copyright (C) 2015 -- 2017 Felix Ballani This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef POLYGON_H #define POLYGON_H 1 /******************************************************************************* * PoissonPolygon.h ****/ // Definitions //#define PI 3.141592653589793238462643383279 // Structs typedef struct vertex { double x[2]; // vertex coordinates } vertex; typedef struct edge { double u[2]; // normal vector double p; // distance from the origin } edge; typedef struct polygon { int n; // number of vertices = number of edges vertex *v; // array of vertices edge *e; // array of edges double box0[2]; // coordinates of the left lower vertex of smallest box containing the polygon double box1[2]; // coordinates of the right upper vertex of smallest box containing the polygon } polygon; // Functions double scProd(const double *x, const double *y); int compareAngles(const void * a, const void * b); void rTriangle(double *phi); int rPoissonPolygon(struct polygon *P, double lambda, bool); //int rPoissonPolygon2(struct polygon *P, double lambda, bool); void freePolygon(struct polygon *P); bool isInside(struct polygon *P, double *x); double getArea(struct polygon *P); #endif /* POLYGON_H */ RandomFields/src/cubicsolver.h0000644000176200001440000000021713437301605016103 0ustar liggesusers#ifndef CUBICSOLVER_H #define CUBICSOLVER_H int cubicsolver(double a, double b, double c, double d, double roots[][2]); #endif // CUBICSOLVER RandomFields/src/init.cov.cc0000644000176200001440000012112713437301605015456 0ustar liggesusers /* Authors Martin Schlather, schlather@math.uni-mannheim.de library for simulation of random fields -- init part Copyright (C) 2001 -- 2017 Martin Schlather This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // to do: V3.1+: Randverteilungen der RPs in cov, D etc implementieren; // do -> random part; init wird innerhalb von do aufgerufen, // falls nicht initialisiert oder random submodels?? // to do: MLE: random parameters einsammeln #include #include #include "RF.h" #include "operator.h" #include "startGetNset.h" #include "primitive.h" #include "shape.h" // wegen fixcov int BROWNIAN, CAUCHY, CUTOFF, GAUSS, GENERALISEDCAUCHY, GENNSST_INTERN, GNEITING_INTERN, MATRIX, NATSC_INTERN, NATSC_USER, NUGGET, MULT, POW, POWER_DOLLAR, PROD, STABLE, STEIN, TBM_OP, TBM2NR, VARIOGRAM2COV, VECTOR; void includeCovModels() { // at the origin: prespecified distribution // old RandomFields ave1,ave2 IncludeModel("ave", PosDefType, 1, 1, 3, kappa_ave, XONLY, SYMMETRIC, checkave, rangeave, PREF_ALL, false, SCALAR, AveMaxDim, (ext_bool) false, NOT_MONOTONE); kappanames("A", REALSXP, "z", REALSXP, "spacetime", INTSXP); addCov(ave, NULL, NULL); RandomShape(structAve, true); SHAPEAVE = IncludeModel("shape.ave", ShapeType, 1, 2, 3, kappa_ave, XONLY, CARTESIAN_COORD, check_shapeave, rangeave, PREF_NOTHING, true, SCALAR, INFDIM-1, (ext_bool) true, NOT_MONOTONE); kappanames("A", REALSXP, "z", REALSXP, "spacetime", INTSXP); subnames("phi", "gauss"); addlogCov(logshapeave); RandomShape(0, init_shapeave, do_shapeave, true); pref_type pbcw = {2, 5, 5, 5, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeScalar("bcw", VariogramType, 0, 0, 3, XONLY, ISOTROPIC, checkbcw, rangebcw, pbcw, INFDIM, (ext_bool) false, NORMAL_MIXTURE); // todo part is even // LAPLACE kappanames("alpha", REALSXP, "beta", REALSXP, "c", REALSXP); addCov(bcw, Dbcw, DDbcw, Inversebcw); addLocal(coinitbcw, ieinitbcw); AddVariant(PosDefType, ISOTROPIC); AddVariant(TcfType, ISOTROPIC); AddVariant(PosDefType, SPHERICAL_ISOTROPIC); IncludeScalar("locstatfbm", PosDefType, 0, 0, 2, XONLY, ISOTROPIC, checklsfbm, rangelsfbm, PREF_ALL, INFDIM, (ext_bool) false, MONOTONE); nickname("lsfbm"); kappanames("alpha", REALSXP, "const", REALSXP); addCov(lsfbm, Dlsfbm, DDlsfbm, D3lsfbm, D4lsfbm, Inverselsfbm); Taylor(-1, RF_NA, 0, 0); TailTaylor(-1, RF_NA, 0, 0); RandomShape(0, struct_failed, initlsfbm, do_failed, false, true, false); pref_type pbessel = {2, 0, 0, 0, 5, 3, 3, 0, 5, 0, 5, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("bessel", PosDefType, 1, XONLY, ISOTROPIC, checkBessel, rangeBessel, pbessel, SCALAR, INFDIM, (ext_bool) false, NOT_MONOTONE); kappanames("nu", REALSXP); addCov(Bessel, NULL, NULL); addTBM(initBessel, spectralBessel); RandomShape(0, struct_failed, initBessel, do_failed, false, true, false); IncludeModel("bigneiting", PosDefType, 0, 0, 8, kappa_biGneiting, XONLY, ISOTROPIC, checkbiGneiting, rangebiGneiting, PREF_ALL, false, 2, PARAM_DEP, (ext_bool) true, NOT_MONOTONE); addCov(biGneiting, DbiGneiting, DDbiGneiting, NULL, NULL); kappanames("kappa", INTSXP, "mu", REALSXP, "s", REALSXP, "sred12", REALSXP, "gamma", REALSXP, "cdiag", REALSXP, "rhored", REALSXP, "c", REALSXP); add_sortof(sortof_biGneiting); RandomShape(0, struct_failed, initbiGneiting, do_failed, false, true, false); pref_type pbernoulli = {5, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("bernoulli", TcfType, 1, 1, 3, NULL, SUBMODEL_D, SUBMODEL_I, checkbinary, rangebinary, pbernoulli, false, SCALAR, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); kappanames("threshold", REALSXP, "correlation", INTSXP, "centred", INTSXP); addCov(binary, NULL, NULL); IncludeModel("biWM", PosDefType, 0, 0, 8, kappa_biWM, XONLY, ISOTROPIC, checkbiWM2, rangebiWM2, PREF_ALL, false, 2, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("biwm"); addCov(biWM2, biWM2D, biWM2DD, biWM2D3, biWM2D4, ErrInverse); addLocal(coinitbiWM2, NULL); kappanames("nudiag", REALSXP, "nured12", REALSXP, "nu", REALSXP, // or lower triangle "s", REALSXP, // lower triangle definition "cdiag", REALSXP, "rhored", REALSXP, "c", REALSXP, // or lower triangle "notinvnu", INTSXP); RandomShape(0, struct_failed, initbiWM2, do_failed, false, true, false); // bivariate stable or bivariate exponetial model //IncludeModel("bistable", PosDefType, 0,0, 4, kappa_biStable, XONLY, ISOTROPIC, IncludeModel("bistable", PosDefType, 0,0, 7, kappa_biStable, XONLY, ISOTROPIC, checkbiStable, rangebiStable, PREF_ALL, false, 2, 3, (ext_bool) false, MONOTONE); kappanames("alpha", REALSXP, "s", REALSXP, // lower triangle definition "cdiag", REALSXP, "rho", REALSXP, "rhored", REALSXP, "betared", REALSXP, "alphadiag", REALSXP ); addCov(biStable, DbiStable, DDbiStable, D3biStable, D4biStable, NULL); addLocal(coinitbiStable, NULL); RandomShape(0, struct_failed, initbiStable, do_failed, false, true, false); //what is this??? pref_type pblend = { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("blend", PosDefType, 2, 2, 1, kappablend, KERNEL, SYMMETRIC, checkblend, rangeblend, pblend, false, SCALAR, SUBMODEL_DEP, falsch, NOT_MONOTONE); subnames("multi", "blend"); kappanames("thresholds", REALSXP); // neg value == auto addCov(nonstatblend); change_sortof(BLEND_THRES, ONLYRETURN); pref_type pbrownresnick = {5, 0, 0, 5, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any BROWNRESNICK = IncludeModel("brownresnick", TcfType, 1, 1, 0, NULL, XONLY, SUBMODEL_I, checkbrownresnick, NULL , pbrownresnick, false, SCALAR, SUBMODEL_DEP, (ext_bool) false, MON_SUB_DEP); addCov(brownresnick, Dbrownresnick, DDbrownresnick, D3brownresnick, NULL, NULL); RandomShape(0, struct_brownresnick, init_brownresnick, do_brownresnick); // Taylor(0, 0, 0, 0, 0, 0, 0, 0); IncludeScalar("br2bg", PosDefType, 1, 1, 0, XONLY, SUBMODEL_I, check_BR2BG, NULL, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, MON_SUB_DEP); addCov(BR2BG, NULL, NULL); IncludeScalar("br2eg", PosDefType, 1, 1, 0, XONLY, SUBMODEL_I, check_BR2EG, NULL, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, MON_SUB_DEP); addCov(BR2EG, NULL, NULL); pref_type pbubble = { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any BUBBLE = IncludeModel("bubble", PosDefType, 1, 2, 4, kappabubble, KERNEL, UNREDUCED, checkbubble, rangebubble, pbubble, false, SCALAR, INFDIM - 1, falsch, NOT_MONOTONE); subnames("phi", "scaling"); kappanames("z", REALSXP, "weight", REALSXP, "minscale", REALSXP, "barycentre", INTSXP); addCov(nonstatbubble); change_sortof(BUBBLE_MINSCALE, ONLYRETURN); change_sortof(BUBBLE_WEIGHT, ONLYRETURN); change_sortof(BUBBLE_Z, ONLYRETURN); // RandomShape(0, struct_failed, initBubble, do_failed, false, true, false); pref_type pcauchy= {2, 5, 0, 2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("cauchy", PosDefType, 1, XONLY, ISOTROPIC, checkCauchy, rangeCauchy, pcauchy, SCALAR, INFDIM, (ext_bool) false, NORMAL_MIXTURE); kappanames("gamma", REALSXP); addCov(Cauchy, DCauchy, DDCauchy, InverseCauchy); // addlogCov(logCauchy); addTBM(TBM2Cauchy); addLocal(coinitCauchy, NULL); addGaussMixture(DrawMixCauchy, LogMixDensCauchy); // todo : WARUM HABE ICH DIESES MODELL CODIERT, ABER NICHT ONLINE?? // pref_type pctbm={2, 0, 0, 5, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any // IncludePrim("cauchytbm", PosDefType, 3, XONLY, ISOTROPIC, checkOK, // rangeCauchytbm, pctbm, SCALAR, INFDIM, (ext_bool) false); // kappanames("alpha", REALSXP, "beta", REALSXP, "gamma", REALSXP); // addCov(Cauchytbm, DCauchytbm, InverseCauchy); // scale not correct, but // should be an approximation that is good enough IncludePrim("circular", TcfType, 0, XONLY, ISOTROPIC, checkOK, NULL, 2, (ext_bool) false, GNEITING_MON); addCov(circular, Dcircular, ScaleOne); RandomShape(structcircular); // IncludePrim("cone", PosDefType, 3, XONLY, ISOTROPIC, checkcone, rangecone); // kappanames("r", REALSXP, "socle", REALSXP, "height", REALSXP); // RandomShape(init_cone, mppget_cone, sd_standard, MPP_POISS); IncludePrim("CDeWijsian", VariogramType, 2, NULL, XONLY, ISOTROPIC, checkdewijsian, rangeDeWijsian, PREF_NOTHING, SCALAR, INFDIM, (ext_bool) false, MONOTONE); nickname("cdewijs"); make_internal(); kappanames("alpha", REALSXP, "range", REALSXP); addCov(DeWijsian, NULL, NULL, InverseDeWijsian); // next model is constant in space, possibly multivariate IncludeModel("constant", PosDefType, 0, 0, 1, kappaconstant, XONLY, PREVMODEL_I, // PREVMODEL_D, PREVMODEL_I, //wegen Variogramm berechnung in stat. Fall checkconstant, rangeconstant, PREF_ALL, false, PARAM_DEP, INFDIM, (ext_bool) false, MON_SUB_DEP); kappanames("M", REALSXP); addCov(constant, NULL, NULL); addCov(nonstatconstant); AddVariant(NegDefType, ISOTROPIC); // AddVariant(TcfType, PREVMODEL_I); // AddVariant(ShapeType, EARTH_ISOTROPIC); // AddVariant(TcfType, EARTH_ISOTROPIC); // AddVariant(ShapeType, SPHERICAL_ISOTROPIC); // AddVariant(TcfType, SPHERICAL_ISOTROPIC); pref_type pfix={0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("fixcov", PosDefType, 0, 1, 3, kappa_fix, KERNEL, UNREDUCED, // zwingend bei RAW-Konstruktionen !! checkfix, rangefix, pfix, INTERN_SHOW, PARAM_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); subnames("norm"); kappanames("M", LISTOF + REALSXP, COVARIATE_X_NAME, VECSXP, COVARIATE_RAW_NAME, INTSXP); change_sortof(COVARIATE_X, DONOTVERIFYPARAM); addCov(fixStat, NULL, NULL); addCov(fix); setptwise(pt_paramdep); addTypeFct(Typefix); setDI(NULL, allowedIfix, NULL); AddVariant(PosDefType, ISOTROPIC); AddVariant(PosDefType, EARTH_ISOTROPIC); pref_type pcox={2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("coxisham", PosDefType, 1, 1, 3, kappa_cox, XONLY, SYMMETRIC, checkcox, rangecox, pcox, false, SCALAR, CoxMaxDim, (ext_bool) false, NOT_MONOTONE); kappanames("mu", REALSXP, "D", REALSXP, "beta", REALSXP); addCov(cox, NULL, NULL); addTBM(initcox, spectralcox); nablahess(coxnabla, coxhess); IncludePrim("cubic", TcfType, 0, XONLY, ISOTROPIC, checkOK, NULL, 3, (ext_bool) false, MONOTONE); addCov(cubic, Dcubic, ScaleOne); pref_type pcurl= {2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("curlfree", PosDefType, 1, 1, 1, kappadivcurl, XONLY, CARTESIAN_COORD, checkdivcurl, rangedivcurl, pcurl, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("which", INTSXP); addCov(curl, NULL, NULL); pref_type plocal={5, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any CUTOFF = IncludeModel("cutoff", PosDefType, 1, 1,2, NULL, XONLY, ISOTROPIC, check_co, range_co, plocal, false, SUBMODEL_DEP, MAXCEDIM, (ext_bool) true, MONOTONE); kappanames("diameter", REALSXP, "a", REALSXP); addCov(co, NULL, NULL); addCallLocal(alternativeparam_co); // warning("siehe Primitive.cc/biWM: cutoff funktioniert nicht bei MLE, vereinheitlichung mit natsc und verbesserung von biWM notwendig"); IncludeModel("dagum", PosDefType, 0, 0, 3, NULL, XONLY, ISOTROPIC, checkdagum, rangedagum, PREF_ALL, false, 1, INFDIM, (ext_bool) false, MON_PARAMETER); kappanames("beta", REALSXP, "gamma", REALSXP, INTERNAL_PARAM, REALSXP); addCov(dagum, Ddagum, Inversedagum); RandomShape(0, struct_failed, initdagum, do_failed, false, true, false); AddVariant(TcfType, ISOTROPIC); AddVariant(PosDefType, SPHERICAL_ISOTROPIC); setptwise(pt_posdef); IncludePrim("dampedcosine", PosDefType, 1, XONLY, ISOTROPIC, checkdampedcosine, rangedampedcosine, PARAM_DEP, (ext_bool) false, NOT_MONOTONE); nickname("dampedcos"); kappanames("lambda", REALSXP); addCov(dampedcosine, Ddampedcosine, Inversedampedcosine); // addlogCov(logdampedcosine); pref_type pderivative= {2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("deriv", PosDefType, 1, 1, 1, kappaderivative, XONLY, CARTESIAN_COORD, checkderivative, rangederivative, pderivative, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("which",INTSXP); addCov(derivative, NULL, NULL); pref_type pdewijsian = {2, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("DeWijsian", VariogramType, 1, XONLY, ISOTROPIC, checkOK, rangedewijsian, pdewijsian, SCALAR, INFDIM, (ext_bool) false, MONOTONE); nickname("dewijsian"); kappanames("alpha", REALSXP); addCov(dewijsian, Ddewijsian, DDdewijsian, D3dewijsian, D4dewijsian, Inversedewijsian); addLocal(coinitdewijsian, NULL); pref_type pdiv= {2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("divfree", PosDefType, 1, 1, 1, kappadivcurl, XONLY, CARTESIAN_COORD, checkdivcurl, rangedivcurl, pdiv, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("which", INTSXP); addCov(diverge, NULL, NULL); pref_type pepsC = {2, 0, 0, 5, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("epsC", PosDefType, 0, 0, 3, NULL, XONLY, ISOTROPIC, checkepsC, rangeepsC, pepsC, false, SCALAR, INFDIM, (ext_bool) false, NORMAL_MIXTURE); nickname("epscauchy"); kappanames("alpha", REALSXP, "beta", REALSXP, "eps", REALSXP); addCov(epsC, DepsC, DDepsC, NULL, NULL); addlogCov(logepsC); IncludePrim("exponential", TcfType, 0, XONLY, ISOTROPIC, checkexponential, NULL, INFDIM, (ext_bool) false, COMPLETELY_MON); nickname("exp"); addCov(0, exponential, Dexponential, DDexponential, Inverseexponential, NULL); addlogCov(logexponential, NULL, nonstatLogInvExp); addLocal(coinitExp, ieinitExp); addHyper(hyperexponential); // numerisches Ergebnis passt nicht ! addGaussMixture(DrawMixExp, LogMixDensExp); addTBM(TBM2exponential, NULL, spectralexponential); RandomShape(1, initexponential, do_exp); Taylor(-1, 1.0, 0.5, 2.0); TailTaylor(1, 0, 1, 1); // operator, replacing any covariance fct C by EXP(C) (componentwise) IncludeScalar("Exp", PosDefType, 1, 1, 2, SUBMODEL_D, SUBMODEL_I, checkExp, rangeExp, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("exponential"); kappanames("n", INTSXP, "standardised", INTSXP); addCov(Exp, DExp, DDExp, NULL, NULL); // setptwise(pt_paramdef); pref_type pextrgauss = {5, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("extremalgauss", TcfType, 1, 1, 0, NULL, XONLY, SUBMODEL_I, check_extrgauss, NULL, pextrgauss, false, SCALAR, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); nickname("schlather"); addCov(extrgauss, NULL, NULL); //X IncludePrim("FD", PosDefType, 1, XONLY, ISOTROPIC, checkOK, rangeFD, 1, (ext_bool) false, NOT_MONOTONE); nickname("fractdiff"); kappanames("a", REALSXP); addCov(FD, NULL, NULL); // same as RMcovariate, ausser dass RMcovariate interpoliert // und CONSTANT mehrere Saetze von covariaten erlaubt??!! IncludePrim("flatpower", VariogramType, 1, XONLY, ISOTROPIC, checkoesting, rangeoesting, INFDIM, (ext_bool) false, BERNSTEIN); // todo BERNSTEIN kappanames("alpha", REALSXP); addCov(2, oesting, Doesting, DDoesting, NULL, NULL); RandomShape(0, initoesting, do_statiso); Taylor(-1, 2, RF_NA, 4, RF_NA, 6); TailTaylor(-1, RF_NA, 0, 0); BROWNIAN = IncludePrim("fractalB", VariogramType, 1, XONLY, ISOTROPIC, checkfractalBrownian, rangefractalBrownian, INFDIM, (ext_bool) false, BERNSTEIN); // todo BERNSTEIN nickname("fbm"); kappanames("alpha", REALSXP); addCov(fractalBrownian, DfractalBrownian, DDfractalBrownian, D3fractalBrownian, D4fractalBrownian, InversefractalBrownian); addlogCov(logfractalBrownian); addLocal(NULL, ieinitBrownian); RandomShape(0, initfractalBrownian, do_statiso); Taylor(-1, RF_NA, 0, 0); TailTaylor(-1, RF_NA, 0, 0); IncludePrim("fractgauss", PosDefType, 1, XONLY, ISOTROPIC, checkOK, rangefractGauss, 1, (ext_bool) false, NOT_MONOTONE); kappanames("alpha", REALSXP); addCov(fractGauss, NULL, NULL); pref_type pgauss= {2, 0, 0, 5, 5, 5, 5, 5, 0, 0, 5, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any GAUSS = // 61 IncludePrim("gauss", PosDefType, 0, XONLY, ISOTROPIC, checkOK, NULL, pgauss, SCALAR, INFDIM, (ext_bool) false, NORMAL_MIXTURE); addCov(Gauss, DGauss, DDGauss, D3Gauss, D4Gauss, InverseGauss); addlogCov(logGauss, NULL, nonstatLogInvGauss); addTBM(NULL, spectralGauss); RandomShape(INFTY, struct_Gauss, initGauss, do_Gauss, false, true, false); addGaussMixture(DrawMixGauss, LogMixDensGauss); Taylor(-1.0, 2.0); TailTaylor(1, 0, 1.0, 2.0); IncludePrim("genB", VariogramType, 2, XONLY, ISOTROPIC, checkOK, rangegenBrownian, INFDIM, (ext_bool) false, MONOTONE); nickname("genfbm"); kappanames("alpha", REALSXP, "beta", REALSXP); addCov(genBrownian, NULL, NULL, InversegenBrownian); addlogCov(loggenBrownian); pref_type pgenc = {2, 0, 0, 2, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("gencauchy", PosDefType, 2, XONLY, ISOTROPIC, checkgeneralisedCauchy, rangegeneralisedCauchy, pgenc, SCALAR, INFDIM, (ext_bool) false, MON_PARAMETER); // todo part is even // LAPLACE kappanames("alpha", REALSXP, "beta", REALSXP); addCov(generalisedCauchy, DgeneralisedCauchy, DDgeneralisedCauchy, InversegeneralisedCauchy); addlogCov(loggeneralisedCauchy); addLocal(coinitgenCauchy, ieinitgenCauchy); AddVariant(TcfType, ISOTROPIC); AddVariant(PosDefType, SPHERICAL_ISOTROPIC); setptwise(pt_posdef); // bivariate stable or bivariate exponnetial model IncludePrim("bicauchy", PosDefType, 4, kappa_biCauchy, XONLY, ISOTROPIC, checkbiCauchy, rangebiCauchy, PREF_ALL, 2, 3, (ext_bool) false, MONOTONE); kappanames("alpha", REALSXP, "beta", REALSXP, "s", REALSXP, // lower triangle definition "rho", REALSXP // lower triangl ); addCov(biCauchy, DbiCauchy, DDbiCauchy, D3biCauchy, D4biCauchy, NULL); addLocal(coinitbiCauchy, NULL); //Y IncludePrim("gengneiting", PosDefType, 2, XONLY, ISOTROPIC, checkgenGneiting, rangegenGneiting, INFDIM-1, (ext_bool) true, MONOTONE); // GNEITING_MON ?? // not INFDIM, also not normalscale mixture and alpha will be void kappanames("kappa", INTSXP, "mu", REALSXP); addCov(genGneiting, DgenGneiting, DDgenGneiting, //NULL, NULL, ScaleOne, NULL); IncludePrim("gengneiting", PosDefType, 2, XONLY, ISOTROPIC, checkgenGneiting, rangegenGneiting, INFDIM-1, (ext_bool) true, MONOTONE); // GNEITING_MON ?? // not INFDIM, also not normalscale mixture and alpha will be void kappanames("kappa", INTSXP, "mu", REALSXP); addCov(genGneiting, DgenGneiting, DDgenGneiting, //NULL, NULL, ScaleOne, NULL); GNEITING_INTERN = IncludeModel("gengneit_intern", PosDefType, 0, 0, 2, NULL, XONLY, ISOTROPIC, checkgenGneiting, rangegenGneiting, PREF_ALL, true, SCALAR, PARAM_DEP, (ext_bool) true, MONOTONE); nickname("gengneiting"); kappanames("kappa", INTSXP, "mu", REALSXP); addCov(Gneiting, DGneiting, DDGneiting, ScaleOne); IncludeScalar("gneiting", PosDefType, 0, 0, 1, XONLY, ISOTROPIC, checkGneiting, rangeGneiting, PREF_ALL, PARAM_DEP, (ext_bool) true, MONOTONE); // GNEITING_MON ?? kappanames("orig", INTSXP); addCov(Gneiting, DGneiting, DDGneiting, ScaleOne); pref_type pfgennsst= { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeScalar("gennsst", PosDefType, 2, 2, 1, SUBMODEL_D, SYMMETRIC, //SUBMODEL_I, checkgennsst, rangegennsst, pfgennsst, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); kappanames("dim_u", INTSXP); addCov(gennsst, NULL, NULL); addCov(nonstatgennsst); setDI(allowedDgennsst, NULL, NULL); //allowedIgennsst); //Y GENNSST_INTERN = // to do: why internal?? IncludeModel("gennsst_intern", PosDefType, // stimmt nicht, aber egal 2, 2, 1, kappa_gennsst_intern, XONLY, SYMMETRIC, checkgennsst_intern, range_gennsst_intern, pfgennsst, true, SCALAR, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("gennsst"); kappanames("A", REALSXP); addCov(gennsst_intern, NULL, NULL); /* pref_type phelmholtz= {2, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("helmholtz", PosDefType, 1, 1, 2, kappamixed, XONLY, SYMMETRIC, checkhelmholtz,rangeHelmholtz, phelmholtz, true, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("component",REALSXP,"Aniso",REALSXP); addCov(helmholtz, NULL, NULL); */ pref_type phyper= {2, 0, 0, 3, 0, 4, 5, 0, 5, 0, 5, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("hyperbolic", PosDefType, 3, XONLY, ISOTROPIC, checkhyperbolic, rangehyperbolic, phyper, SCALAR, INFDIM, (ext_bool) false, NORMAL_MIXTURE); kappanames("nu", REALSXP, "lambda", REALSXP, "delta", REALSXP); addCov(hyperbolic, Dhyperbolic, NULL); // InversehyperbolicSq); addlogCov(loghyperbolic); RandomShape(0, struct_failed, inithyperbolic, do_failed, false, true, false); IncludePrim("iacocesare", PosDefType, 3, XONLY, DOUBLEISOTROPIC, checkOK, rangeIacoCesare, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("iaco"); kappanames("nu", REALSXP, "lambda", REALSXP, "delta", REALSXP); addCov(IacoCesare, NULL, NULL); IncludeModel("identity", ManifoldType, 1,1, 1, NULL, PREVMODEL_D, PREVMODEL_I, checkId, rangeId, PREF_ALL, false, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); nickname("idmodel"); kappanames("vdim", INTSXP); addCov(IdStat, DId, DDId, IdInverse); addCov(IdNonStat); addTBM(TBM2Id, initId, spectralId); addLocal(coinitId, ieinitId); addTypeFct(TypeId); IncludePrim("kolmogorov", VariogramType, 0, XONLY, VECTORISOTROPIC, checkKolmogorov, NULL, 3, 3, (ext_bool) false, NOT_MONOTONE); addCov(Kolmogorov, NULL, NULL); pref_type plgd1= {2, 0, 0, 5, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("lgd1", PosDefType, 2, NULL, XONLY, ISOTROPIC, checklgd1, rangelgd1, plgd1, SCALAR, PARAM_DEP, (ext_bool) false, MONOTONE); nickname("lgd"); kappanames("alpha", REALSXP, "beta", REALSXP); addCov(lgd1, Dlgd1, NULL); // Inverselgd1); // stimmt so nicht, siehe Gneiting 1998, on a alpha-sym multiv. char. fct: // IncludeModel("lp", PosDefType, 1, 1, 1, XONLY, SYMMETRIC, // checklp, rangelp, // (pref_type) {5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5} // // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any // ); // kappanames("p", REALSXP); // addCov(lp, NULL, NULL); IncludeScalar("mastein", PosDefType, 1, 1, 2, XONLY, DOUBLEISOTROPIC, check_MaStein, range_MaStein, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); kappanames("nu", REALSXP, "delta", REALSXP); addCov(MaStein, NULL, NULL); IncludeScalar("ma1", PosDefType, 1, 1, 2, XONLY, SYMMETRIC, checkma1, rangema1, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("ma"); kappanames("alpha", REALSXP, "theta", REALSXP); addCov(ma1, NULL, NULL); IncludeScalar("ma2", PosDefType, 1, 1, 0, XONLY, SYMMETRIC, checkma2, NULL, PREF_ALL, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); nickname("intexp"); addCov(ma2, NULL, NULL); //X pref_type pmatrix = {3, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 3, 5}; // CE CO CI TBM Sp di sq Tr av n mpp Hy spf any MATRIX= IncludeModel("M", ManifoldType, 1, MAXSUB, 2, kappaM, SUBMODEL_D, SUBMODEL_I, checkM, rangeM, pmatrix, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); nickname("matrix"); kappanames("M", REALSXP, "vdim", INTSXP); // vdim ist das interne! change_typeof(M_M, ShapeType); addCov(Mstat, NULL, NULL); addCov(Mnonstat); add_sortof(sortof_M); addTypeFct(TypeM); RandomShape(0, struct_failed, initM, do_failed, false, true, false); setDI(allowedDM, allowedIM, NULL); IncludeScalar("matern", PosDefType, 0, 0, 2, PARAMDEP_D, PARAMDEP_I, checkMatern, rangeWM, PREF_ALL, INFDIM, (ext_bool) false, MON_SUB_DEP); kappanames("nu", REALSXP, "notinvnu", INTSXP); change_sortof(WM_NU, CRITICALPARAM); change_typeof(WM_NU, RandomOrShapeType); change_sortof(WM_NOTINV, ONLYRETURN); addCov(Matern, DMatern, DDMatern, D3Matern, D4Matern, InverseMatern); addCov(NonStMatern); addlogCov(logMatern, logNonStMatern, NULL); addTBM(initMatern, spectralMatern); addLocal(coinitWM, ieinitWM); setptwise(pt_posdef); setDI(allowedDWM, allowedIWM, setWM); addTypeFct(TypeWM); RandomShape(0, struct_failed, initWM, do_failed, false, true, false); // addGaussMixture(DrawMixWM, LogMixDensWM); IncludeModel("mqam", PosDefType, 2, 10, 1, kappamqam, XONLY, SYMMETRIC, checkmqam, rangemqam, PREF_ALL, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); subnames("phi"); kappanames("theta", REALSXP); change_sortof(QAM_THETA, CRITICALPARAM); addCov(mqam, NULL, NULL); pref_type pmultiquad = {0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("multiquad", PosDefType, 2, NULL, XONLY, SPHERICAL_ISOTROPIC, checkOK, rangemultiquad, pmultiquad, SCALAR, 2, (ext_bool) false, MONOTONE); kappanames("delta", REALSXP, "tau", REALSXP); addCov(multiquad, NULL, NULL); NATSC_INTERN =NATSC_USER = IncludeModel("natsc", PosDefType, 1, 1, 0, NULL, XONLY, ISOTROPIC, checknatsc, NULL, PREF_ALL, false, 1, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); // nie einen Parameter ! addCov(natsc, Dnatsc, DDnatsc, Inversenatsc); addLocal(coinitnatsc, ieinitnatsc); addTBM(tbm2natsc, initnatsc, spectralnatsc); setptwise(pt_submodeldep); AddVariant(TcfType, ISOTROPIC); // NATSC_INTERN = CopyModel("natsc_intern", NATSC_USER); // make_internal(); pref_type pfnsst= { 4, 0, 0, 2, 0, 5, 4, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeScalar("nsst", PosDefType, 2, 2, 1, XONLY, DOUBLEISOTROPIC, checknsst, rangensst, pfnsst, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); subnames("phi", "psi"); kappanames("delta", REALSXP); change_sortof(NSST_DELTA, CRITICALPARAM); addCov(nsst, Dnsst, NULL); addTBM(TBM2nsst); setptwise(pt_posdef); // IncludePrim("nsst2", 7, checknsst2, DOUBLEISOTROPIC, // rangensst2); // addCov(nsst2, Dnsst2, NULL); // addTBM(NULL, NULL /* TBM3nsst2 */); IncludeModel("parsWM", PosDefType, 0, 0, 1, kappa_parsWM, XONLY, ISOTROPIC, checkparsWM, rangeparsWM, PREF_ALL, false, PARAM_DEP, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("parswm"); addCov(parsWM, parsWMD, NULL); kappanames("nudiag", REALSXP); change_sortof(PARSnudiag, CRITICALPARAM); setptwise(pt_posdef); RandomShape(0, struct_failed, initparsWM, do_failed, false, true, false); IncludePrim("penta", PosDefType, 0, XONLY, ISOTROPIC, checkOK, NULL, 3, (ext_bool) true, MONOTONE); addCov(penta, Dpenta, ScaleOne); IncludePrim("power", PosDefType, 1, XONLY, ISOTROPIC, checkpower, rangepower, INFDIM-1, (ext_bool) true, MONOTONE); nickname("askey"); kappanames("alpha", REALSXP); addCov(power, Dpower, ScaleOne); AddVariant(TcfType, ISOTROPIC); // AddVariant(PosDefType, SPHERICAL_ISOTROPIC); // FORMERLY DIFFERENR DEFs OF PARAMs POW = IncludeScalar("Pow", ShapeType, 1, 1, 1, XONLY, SUBMODEL_I, checkPow, rangePow, PREF_ALL, SUBMODEL_DEP, Submodeldep, NOT_MONOTONE); nickname("power"); addCov(Pow, DPow, DDPow, InversePow); kappanames("alpha", REALSXP); setptwise(pt_posdef); AddVariant(NegDefType, SUBMODEL_I); AddVariant(PosDefType, SUBMODEL_I); AddVariant(TcfType, ISOTROPIC); RandomShape(0, struct_failed, initPow, do_failed, false, false, false); pref_type pfprod= { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any PROD = IncludeModel("prod", PosDefType, 1, 1, 0, NULL, KERNEL, UNREDUCED, checkprod, NULL, pfprod, false, SUBMODEL_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); addCov(nonstatprod); subnames("phi"); // AddVariant(PosDefType, SPHERICAL_COORD); // AddVariant(PosDefType, EARTH_COORD); setptwise(pt_posdef); // printf("nick=%.50s\n", DefList [currentNrCov - 1].nick); IncludeModel("qam", PosDefType, 2, MAXSUB, 1, kappaqam, XONLY, ISOTROPIC, checkqam, rangeqam, PREF_ALL, false, SCALAR, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); kappanames("theta", REALSXP); subnames("phi"); addCov(qam, NULL, NULL); change_sortof(QAM_THETA, CRITICALPARAM); IncludePrim("qexponential", PosDefType, 1, XONLY, ISOTROPIC, checkOK, rangeqexponential, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("qexp"); kappanames("alpha", REALSXP); addCov(qexponential, Dqexponential, Inverseqexponential); pref_type pscale = { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any SCALEMODEL = IncludeModel("scale", PosDefType, 2, 3, 0, NULL, KERNEL, SYMMETRIC, checkscale, NULL, pscale, false, SCALAR, INFDIM - 1, falsch, NOT_MONOTONE); subnames("phi", "scaling", "penalty"); addCov(nonstatscale); IncludeModel("schur", PosDefType, 1, 1, 3, kappaSchur, PREVMODEL_D, PREVMODEL_I, checkSchur, rangeSchur, PREF_ALL, false, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("M", REALSXP, "diag", REALSXP, "rhored", REALSXP); addCov(Schurstat, DSchur, D2Schur, D3Schur, D4Schur, NULL); addCov(Schurnonstat); add_sortof(sortof_M); IncludeModel("shift", PosDefType, 1, 1, 1, kappashift, XONLY, CARTESIAN_COORD, checkshift, rangeshift, PREF_ALL, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); nickname("delay"); // delayeffect addCov(shift, NULL, NULL); kappanames("s", REALSXP); pref_type psinepower = {0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("sinepower", PosDefType, 1, NULL, XONLY, SPHERICAL_ISOTROPIC, checkOK, rangesinepower, psinepower, SCALAR, 2, (ext_bool) false, MONOTONE); kappanames("alpha", REALSXP); addCov(sinepower, NULL, NULL); IncludePrim("spherical", TcfType, 0, NULL, XONLY, ISOTROPIC, checkOK, NULL, 3, (ext_bool) true, GNEITING_MON); nickname("spheric"); addCov(spherical, Dspherical, DDspherical, ScaleOne); addTBM(TBM2spherical); RandomShape(1, structspherical, initspherical, dospherical, false, true, false); Taylor(-3.0, 1.0, 0.5, 3.0); IncludePrim("stable", PosDefType, 1, XONLY, ISOTROPIC, checkstable, rangestable, INFDIM, (ext_bool) false, MON_PARAMETER); kappanames("alpha", REALSXP); addCov(stable, Dstable, DDstable, Inversestable); addlogCov(logstable, NULL, nonstatLogInversestable); addLocal(coinitstable, ieinitstable); AddVariant(TcfType, ISOTROPIC); AddVariant(PosDefType, SPHERICAL_ISOTROPIC); setptwise(pt_posdef); // DOUBLEISOTROPIC variant of stable -- used for testing purposes only // IncludePrim("stableX", 1, checkOK, DOUBLEISOTROPIC, // rangestable); // addCov(stableX, DstableX, Inversestable); // addTBM(NULL, NULL) STEIN = IncludeModel("Stein", PosDefType, 1, 1, 2, NULL, XONLY, ISOTROPIC, check_Stein, range_Stein, plocal, false, SCALAR, MAXCEDIM, (ext_bool) true, NOT_MONOTONE); nickname(METHOD_NAMES[CircEmbedIntrinsic]); kappanames("diameter", REALSXP, "rawR", REALSXP); change_sortof(pLOC_DIAM, FORBIDDENPARAM); change_sortof(pLOC_A, FORBIDDENPARAM); addCov(Stein, NULL, NULL); addCallLocal(alternativeparam_Stein); // RandomShape(struct_ce_approx, init_ce_approx, do_ce_approx); IncludePrim("steinst1", PosDefType, 2, kappaSteinST1, XONLY, SYMMETRIC, checkSteinST1, rangeSteinST1, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("stein"); kappanames("nu", REALSXP, "z", REALSXP); addCov(SteinST1, NULL, NULL); addTBM(initSteinST1, spectralSteinST1); RandomShape(0, struct_failed, initSteinST1, do_failed, false, true, false); IncludeModel("stp", PosDefType, 1, 2, 3, kappa_stp, KERNEL, SYMMETRIC, checkstp, rangestp, PREF_ALL, false, SCALAR, StpMaxDim, (ext_bool) false, NOT_MONOTONE); addCov(stp); kappanames("S", REALSXP, "z", REALSXP, "M", REALSXP); change_typeof(STP_S, ShapeType); RandomShape(structStp, true); subnames("xi", "phi"); // H ueberall wo U-x steht. dort U-H(x) // gedoppelte immer zum Schluss! SHAPESTP = IncludeModel("shape.stp", ShapeType, 1, 4, 3, kappa_stp, KERNEL, CARTESIAN_COORD, check_shapestp, rangestp, PREF_NOTHING, true, SCALAR, StpMaxDim, (ext_bool) true, NOT_MONOTONE); kappanames("S", REALSXP, "z", REALSXP, "M", REALSXP); addlogCov(logshapestp); subnames("xi2", "phi", "SXX", "gauss"); // hier gedoppeltes S nicht am Schluss // da auf checkstp zugreifend RandomShape(0, init_shapestp, do_shapestp); TBM_OP = // old RandomFields tbm2, tbm3 IncludeModel("tbm", ManifoldType, 1, 1, 3, NULL, XONLY, PARAMDEP_I, checktbmop, rangetbmop, PREF_ALL, false, SUBMODEL_DEP, PARAM_DEP, (ext_bool) PARAM_DEP, NOT_MONOTONE); kappanames("fulldim", INTSXP, "reduceddim", INTSXP, "layers", INTSXP); change_sortof(TBMOP_LAYERS, ONLYRETURN); // NA will not be estimated addCov(tbm, NULL, NULL); // Dtbm, NULL); todo setDI(NULL, allowedItbm, settbm); addTypeFct(Typetbm); // { int i; for (i=0; i<=Nothing; i++) printf("%d %d\n ", i, DefList[TREND].pref[i]); assert(false); } pref_type pfsum= { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludeModel("sum", NegDefType, 0, 1, 0, NULL, KERNEL, UNREDUCED, checksum, NULL, pfsum, false, SUBMODEL_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); addCov(nonstatsum); subnames("phi"); USER = IncludeModel("U", ManifoldType, 0, 0, 16, kappaUser, PARAMDEP_D, PARAMDEP_I, checkUser, rangeUser, PREF_AUX, true,// FREEVARIABLE vorhanden. Muss extra in SpecialRMmodel.R // definiert und nicht ueber generatemodels.R PARAM_DEP, INFDIM, (ext_bool) false, // per default. NOT_MONOTONE); nickname("user"); kappanames("type", INTSXP, "domain", INTSXP, "isotropy", INTSXP, "vdim", INTSXP, "beta", REALSXP, "coordnames", INTSXP, "fctn", LANGSXP, "fst", LANGSXP, "snd", LANGSXP, "envir", ENVSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP //, "trd", LANGSXP ); // H ueberall wo U-x steht. dort U-H(x) addCov(User, DUser, DDUser, NULL, NULL); addCov(UserNonStat); setDI(allowedDuser, allowedIuser, setUser); addTypeFct(TypeUser); /* IncludeModel("gamma2cov", PosDefType, 1, 1, 1, kappaGammaToCov, KERNEL, SYMMETRIC, checkGammaToCov, rangeGammaToCov, pg2c, false, SCALAR, SUBMODEL_DEP, (ext_bool) false, NOT_MONOTONE); kappanames("x0", REALSXP); addCov(GammaToCov); */ pref_type pg2c = { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any VARIOGRAM2COV = // intern ok IncludeModel("cov", PosDefType, 1, 1, 2, kappavariogram2cov, KERNEL, CARTESIAN_COORD, checkvariogram2cov, rangevariogram2cov, pg2c, INTERN_SHOW, SCALAR, INFDIM-1, (ext_bool) false, NOT_MONOTONE); subnames("gamma"); kappanames("x", VECSXP, "a", REALSXP); // change_typeof(VAR2COV_X, MixedInputType, RMCOV_X); change_sortof(VAR2COV_X, DONOTVERIFYPARAM); addCov(variogram2cov); VECTOR = IncludeModel("vector", PosDefType, 1, 1, 2, NULL, XONLY, CARTESIAN_COORD, checkvector, rangevector, PREF_ALL, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); addCov(vector, NULL, NULL); kappanames("a", REALSXP, "Dspace", INTSXP); addFurtherCov(vectorAniso, NULL); pref_type pwave = {2, 0, 0, 0, 5, 4, 5, 0, 0, 0, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any IncludePrim("wave", PosDefType, 0, XONLY, ISOTROPIC, checkOK, NULL, pwave, SCALAR, 3, (ext_bool) false, NOT_MONOTONE); addCov(wave, NULL, Inversewave); addTBM(initwave, spectralwave); IncludeScalar("whittle", PosDefType, 0,0, 2, PARAMDEP_D, PARAMDEP_I, checkWM, rangeWM, PREF_ALL, INFDIM, (ext_bool) false, NORMAL_MIXTURE); kappanames("nu", REALSXP, "notinvnu", INTSXP); change_typeof(WM_NU, RandomOrShapeType); change_sortof(WM_NU, CRITICALPARAM); addCov(Whittle, DWhittle, DDWhittle, D3Whittle, D4Whittle, InverseWhittle); addCov(NonStWhittle); addlogCov(logWhittle, logNonStWhittle, NULL); addTBM(initWhittle, spectralWhittle); addLocal(coinitWM, ieinitWM); addGaussMixture(DrawMixWM, LogMixDensW); setptwise(pt_posdef); setDI(allowedDWM, allowedIWM, setWM); addTypeFct(TypeWM); RandomShape(0, struct_failed, initWM, do_failed, false, true, false); ////////////////////////////////////////////////////////////////////// for (int nr=0; nrname); for (int i=0; ipref[i]; C->pref[i] *= C->implemented[i]==IMPLEMENTED; // if (old != C->pref[i] && i!=Nugget) printf("%.50s:%d%d ", METHOD_NAMES[i], old, C->pref[i]); // && i!=Specific } C->pref[Nothing] *= (C->cov != ErrCov || C->nonstat_cov != ErrCovNonstat); } ////////////////////////////////////////////////////////////////////// pref_type pfnugget= { 1, 0, 0, 0, 0, 1, 1, 0, 0, 5, 0, 0, 0, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any NUGGET = IncludeModel("nugget", TcfType, 0, 0, 2, NULL, // XONLY, ISOTROPIC, PARAMDEP_D, PARAMDEP_I, check_nugget, range_nugget, pfnugget, false, PREVMODEL_DEP, INFDIM, (ext_bool) true, MONOTONE); kappanames("tol", REALSXP, "vdim", INTSXP); change_sortof(NUGGET_TOL, FORBIDDENPARAM); change_sortof(NUGGET_VDIM, FORBIDDENPARAM); addCov(nugget, NULL, Inversenugget); addCov(nuggetnonstat); addReturns(covmatrix_nugget, iscovmatrix_nugget); // AddVariant(TcfType, EARTH_ISOTROPIC); //AddVariant(TcfType, SPHERICAL_ISOTROPIC); setDI(allowedDnugget, allowedInugget, setnugget); addTypeFct(Typenugget); } RandomFields/src/init.others.cc0000644000176200001440000013576113437301605016204 0ustar liggesusers/* Authors Martin Schlather, schlather@math.uni-mannheim.de library for simulation of random fields -- init part Copyright (C) 2017 -- 2018 Martin Schlather This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "RF.h" #include "startGetNset.h" #include "Processes.h" #include "shape.h" #include "rf_interfaces.h" #include "primitive.others.h" #include "operator.h" int BALL, DISTRIBUTION, DETERM_DISTR, GAUSS_DISTR, SETPARAM, COVFCTN, ANGLE, COVMATRIX, RFGET, STROKORB_MONO, STROKORB_BALL_INNER, RECTANGULAR, CONST, BIND, POLYGON, SCATTER, MCMC_PGS, MCMC,LIKELIHOOD_CALL, LINEARPART_CALL, PREDICT_CALL, IDCOORD, MULT_INVERSE, TRUNCSUPPORT, SHAPESTP, SHAPEAVE, BROWNRESNICK, UNIF, MPPPLUS, BRSHIFTED_USER, BRMIXED_USER, BRORIGINAL_USER, BRNORMED, BRSHIFTED_INTERN, BRMIXED_INTERN, BRORIGINAL_INTERN, EXTREMALGAUSSIAN, RANDOMSIGN, ARCSQRT_DISTR, SHAPEPOW, ZHOU, BALLANI, STATIONARY_SHAPE, STANDARD_SHAPE, LOC, SET_DISTR, SCALESPHERICAL, TREND, // TREND_PROC, COVARIATE, TRAFO, TRAFOPROC, PROJMODEL, VARIOGRAM_CALL, SIMULATE, MISSING_COV, NULL_MODEL, DOLLAR_PROC,R, PLUS_PROC, M_PROC, MPPPLUS_PROC, MULT_PROC, BINARYPROC, BROWNRESNICKPROC, GAUSSPROC, POISSONPROC, SCHLATHERPROC, SMITHPROC, CHI2PROC, EXTREMALTPROC, TPROC, TREND_PROC, PROD_PROC, VAR2COV_PROC, NUGGET_USER, NUGGET_INTERN, CIRCEMBED, SPECTRAL_PROC_USER, SPECTRAL_PROC_INTERN, DIRECT, SEQUENTIAL, SPECIFIC, SELECTNR, AVERAGE_USER, AVERAGE_INTERN, HYPERPLANE_USER, HYPERPLANE_INTERN, RANDOMCOIN_USER, CE_CUTOFFPROC_USER, CE_CUTOFFPROC_INTERN, CE_INTRINPROC_USER, CE_INTRINPROC_INTERN, TBM_PROC_USER, TBM_PROC_INTERN, SCALEMODEL, BUBBLE ; void includeOtherModels() { MISSING_COV = IncludePrim("missing", OtherType, 0, XONLY, CARTESIAN_COORD, checkMissing, NULL, INFDIM, (ext_bool) true, NOT_MONOTONE); make_internal(); NULL_MODEL = IncludePrim("null", ManifoldType, 1, XONLY, ISOTROPIC, checkOK, rangeNullModel, INFDIM, (ext_bool) true, NOT_MONOTONE); kappanames("type", INTSXP); addCov(0, NullModel, NullModel, NullModel, NullModel, NULL); RandomShape(INFTY, structOK, initOK, doOK, do_random_ok, false, false, false); make_internal(); addTypeFct(TypeNullModel); // ******************* // **** trend-models **** // ****************** pref_type ptrend = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any TREND = IncludeModel("trend", TrendType, 0, 0, 1, kappatrend, XONLY, PARAMDEP_I, checktrend, rangetrend, ptrend, false, PARAM_DEP, INFDIM, (ext_bool) false, NOT_MONOTONE); // kappanames("mean", REALSXP, "plane", REALSXP, "polydeg", // INTSXP, "polycoeff", //REALSXP, "arbitrark2xyfct", CLOSXP, "fctcoeff", REALSXP); kappanames("mean", REALSXP); change_sortof(TREND_MEAN, TRENDPARAM); change_typeof(TREND_MEAN, ShapeType); addCov(trend, NULL, NULL); setDI(NULL, allowedItrend, settrend); addTypeFct(Typetrend); // addCov(trend_nonstat); // ******************* // **** definite functions **** // ******************* SELECTNR = // to do: replace by parameter in '+', selecting the 'type' or // 'models' IncludeModel("select", TcfType, 1, MAXSUB, 1, NULL, SUBMODEL_D, SUBMODEL_I, checkselect, rangeselect, PREF_ALL, true, PARAM_DEP, INFDIM, (ext_bool)SUBMODEL_DEP, NOT_MONOTONE); kappanames("subnr", INTSXP); addCov(select, NULL, NULL); setDI(allowedDselect, allowedIselect, NULL); addReturns(covmatrix_select, iscovmatrix_select); // ******************* // **** shape types **** // ******************* ANGLE = IncludeModel("angle", ShapeType, 0, 0, 4, kappa_Angle, XONLY, CARTESIAN_COORD, checkAngle, rangeAngle, PREF_NOTHING, false, PARAM_DEP, INFDIM, (ext_bool) false, NOT_MONOTONE); nickname("angle"); addCov(Angle, NULL, NULL, invAngle, NULL); kappanames("angle", REALSXP, "lat.angle", REALSXP, "ratio", REALSXP, "diag", REALSXP); BALL= IncludePrim("ball", ShapeType, 0, NULL, XONLY, ISOTROPIC, checkOK, NULL, PREF_NOTHING, SCALAR, INFDIM-1, (ext_bool) true, MONOTONE); addCov(ball, NULL, NULL, Inverseball); RandomShape(INFTY, struct_ball, init_ball, do_ball); Taylor(1.0, 0.0); COVARIATE = // intern ok IncludeModel("covariate", ShapeType, 0, 1, 5, kappa_covariate, XONLY, UNREDUCED, // zwingend bei RAW-Konstruktionen !! checkcovariate, rangecovariate, PREF_NOTHING, INTERN_SHOW, PARAM_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); subnames("norm"); kappanames(COVARIATE_C_NAME, LISTOF + REALSXP, COVARIATE_X_NAME, VECSXP, COVARIATE_RAW_NAME, INTSXP, COVARIATE_ADDNA_NAME, INTSXP, "factor", REALSXP); change_sortof(COVARIATE_X, DONOTVERIFYPARAM); change_sortof(COVARIATE_ADDNA, IGNOREPARAM); change_sortof(COVARIATE_FACTOR, TRENDPARAM); addCov(covariate, NULL, NULL); setptwise(pt_paramdep); AddVariant(ShapeType, ISOTROPIC); // only if CovarianceMatrix with distances AddVariant(ShapeType, EARTH_ISOTROPIC); AddVariant(TrendType, UNREDUCED); setDI(NULL, allowedIfix, NULL); // epsC has been for internal reasons only ; essentially // the gencauchy model, except that 1 in the denominator // is replaced by epsilon IncludeModel("declare", // never change name without checking all .cc, .R // TrendType, // warum trend?? TcfType, 0, 0, 16, NULL, PREVMODEL_D, PREVMODEL_I, checkdeclare, rangedeclare, PREF_ALL, true, PARAM_DEP, INFDIM, falsch, NOT_MONOTONE); // kappanames("mean", REALSXP, "plane", REALSXP, "polydeg", // INTSXP, "polycoeff", //REALSXP, "arbitrark2xyfct", CLOSXP, "fctcoeff", REALSXP); kappanames(FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP); addCov(0, declarefct, declarefct, declarefct, NULL, NULL); addCov(declarefctnonstat); AddVariant(TrendType, PREVMODEL_I); IncludePrim("EAxxA", ShapeType, 2, kappa_EAxxA, XONLY, CARTESIAN_COORD, checkEAxxA, rangeEAxxA, PREF_NOTHING, PARAM_DEP, EaxxaMaxDim, (ext_bool) false, NOT_MONOTONE); nickname("eaxxa"); addCov(EAxxA, NULL, NULL); kappanames("E", REALSXP, "A", REALSXP); addSpecial(minmaxEigenEAxxA); IncludePrim("EtAxxA", ShapeType, 3, kappa_EtAxxA, XONLY, CARTESIAN_COORD, checkEtAxxA, rangeEtAxxA, 3, EaxxaMaxDim, (ext_bool) false, NOT_MONOTONE); nickname("etaxxa"); addCov(EtAxxA, NULL, NULL); kappanames("E", REALSXP, "A", REALSXP, "alpha", REALSXP); addSpecial(minmaxEigenEtAxxA); IDCOORD = // ACHTUNG falls internal geaendert, auch in KeyInfo.cc aendern IncludeModel("id", ShapeType, 0, 0, 0, NULL, XONLY, PREVMODEL_I, checkidcoord, NULL, PREF_NOTHING, false, PARAM_DEP, INFDIM, (ext_bool) false, NOT_MONOTONE); addCov(idcoord, NULL, NULL); TRAFO = // IncludeModel("trafo", ManifoldType, 0, 1, 1, NULL, PREVMODEL_D, PREVMODEL_I, IncludeModel("trafo", ManifoldType, 0, 1, 1, kappatrafo, PARAMDEP_D, PARAMDEP_I, checktrafo, rangetrafo, PREF_ALL, false, PARAM_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); kappanames("new", INTSXP); change_typeof(TRAFO_ISO, NN2); // ISO_NAMES addCov(trafo, NULL, NULL); addCov(nonstattrafo);// addlogCov(logtrafo, lognonstattrafo, NULL); subnames("phi"); setDI(allowedDtrafo, allowedItrafo, settrafo); addTypeFct(Typetrafo); MULT_INVERSE = IncludeModel("mult_inverse", ShapeType, 1, 1, 0, NULL, PREVMODEL_D, PREVMODEL_I, checkmult_inverse, NULL, PREF_NOTHING, true, SCALAR, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addCov(mult_inverse, NULL, NULL); addCov(mult_inverseNonstat); POLYGON = IncludeModel("polygon", ShapeType, 0, 0, 1, NULL, XONLY, CARTESIAN_COORD, check_polygon, range_polygon, PREF_NOTHING, false, SCALAR, 2, (ext_bool) true, MONOTONE); kappanames("lambda", REALSXP); addCov(Polygon, NULL, NULL, Inversepolygon, InversepolygonNonstat); RandomShape(INFTY, struct_polygon, init_polygon, doOK); IncludePrim("rational", ShapeType, 2, kappa_rational, XONLY, CARTESIAN_COORD, checkrational, rangerational, INFDIM, (ext_bool) false, NOT_MONOTONE); addCov(rational, NULL, NULL); kappanames("A", REALSXP, "a", REALSXP); addSpecial(minmaxEigenrational); IncludePrim("rotat", ShapeType, 2, kappa_rotat, XONLY, CARTESIAN_COORD, checkrotat, rangerotat, PREF_NOTHING, SCALAR, 3, (ext_bool) false, NOT_MONOTONE); addCov(rotat, NULL, NULL); kappanames("speed", REALSXP, "phi", REALSXP); addSpecial(minmaxEigenrotat); IncludePrim("Rotat", ShapeType, 1, kappa_Rotat, XONLY, CARTESIAN_COORD, checkRotat, rangeRotat, PARAM_DEP, 3, (ext_bool) false, NOT_MONOTONE); nickname("rotation"); addCov(Rotat, NULL, NULL); kappanames("phi", REALSXP); SCATTER = IncludeModel("scatter", PosDefType, 1, 1, 2, NULL, PREVMODEL_D, PREVMODEL_I, checkScatter, rangeScatter, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); kappanames("size", REALSXP, "max", INTSXP); addCov(Scatter, NULL, NULL); RandomShape(1, struct_scatter, init_scatter, do_scatter, false, false, false); // true, true, false); RANDOMSIGN = IncludeModel("sign", ShapeType, 1, 1, 1, NULL, XONLY, PREVMODEL_I, check_randomSign, range_randomSign, PREF_NOTHING, false, SCALAR, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, NOT_MONOTONE); //nickname(""); kappanames("p", REALSXP); addCov(randomSign, NULL, NULL, randomSignInverse, randomSignNonstatInverse); addlogCov(lograndomSign); RandomShape(1, struct_randomSign, init_randomSign, do_randomSign, true, true, false); SETPARAM = // nur Handling von Parametern von shape nach pts IncludeModel("setparam", ManifoldType, 1, 1, 1, NULL, PREVMODEL_D, PREVMODEL_I, checksetparam, range_setparam, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); nickname("setparam"); kappanames("performDo", INTSXP); addCov(setparamStat, Dsetparam, DDsetparam, D3setparam, D4setparam, Inverse_setparam, NonstatInverse_setparam); addCov(setparamNonStat); addTBM(NULL, spectralsetparam); RandomShape(INFTY, struct_failed, initsetparam, dosetparam, false, false, true); addReturns(covmatrix_setparam, iscovmatrix_setparam); addTypeFct(Typesetparam); STROKORB_MONO = IncludeModel("m2r", ShapeType, 1, 1, 0, NULL, XONLY, ISOTROPIC, checkstrokorb, NULL, PREF_NOTHING, false, SCALAR, 3, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addCov(strokorb, NULL, NULL); RandomShape(1, structOK, init_strokorb, do_strokorb, false, false, false); #define balltest !true IncludeModel("m3b", ShapeType, 1, 1, balltest ? 2 : 0, NULL, XONLY, ISOTROPIC, checkstrokorbBall, balltest ? rangestrokorbball : NULL,/*for testing only*/ PREF_NOTHING, false, SCALAR, 3, (ext_bool) true, MONOTONE); if (balltest) kappanames("min", REALSXP, "max", REALSXP); addCov(strokorbBallInner, NULL, NULL); RandomShape(1, struct_strokorbBall, init_failed, do_failed, do_random_failed, false, false, false); STROKORB_BALL_INNER = // !! inverse scale gegenueber paper IncludeModel("r3binner", ShapeType, 1, 1, 1, NULL, XONLY, CARTESIAN_COORD, check_strokorbBallInner, range_strokorbBallInner, PREF_AUX, true, 1, 1, (ext_bool) true, NOT_MONOTONE); kappanames("dim", INTSXP); addCov(strokorbBallInner, NULL, NULL); RandomShape(1, init_strokorbBallInner, do_strokorbBallInner); /* da wiederum gewichtet und zwar mit b^2 falls b die intensitaet. kann nicht in dichte function g(b) reingezogen werden, da b^2 g(b) nicht integrierbar. Stattdessen darf f (Dichte im Raum) nicht die Gleichverteilung sein, sondern bei grossen b um die zu simulierenden Punkte zusammenschrumpfen. Dabei nimmt man an, dass die Radien ein Vielfaches des mittleren Radius nicht ueberschreiten. Dies ist OK, da ungefaehr exponentielles Abfallen der WK. */ IncludeModel("mps", ShapeType, 1, 1, 0, NULL, XONLY,CARTESIAN_COORD, checkstrokorbPoly, NULL, PREF_AUX, false, SCALAR, INFDIM, falsch, NOT_MONOTONE); addCov(strokorbPoly, NULL, NULL); RandomShape(1, struct_strokorbPoly, init_failed, do_failed, do_random_failed, false, false, false); TRUNCSUPPORT = IncludeModel("truncsupport", ShapeType, 1, 1, 1, NULL, XONLY, PREVMODEL_I, checktruncsupport, rangetruncsupport, PREF_NOTHING, false, SCALAR, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); kappanames("radius", REALSXP); // neg value == auto addCov(truncsupport, NULL, NULL, truncsupportInverse, StandardInverseNonstat); RandomShape(0, struct_truncsupport, init_truncsupport, do_truncsupport, false, false, false); ////////////////////////////////////////////////// // families of multivariate distribution; used in // ACHTUNG!! addCov muss ganz zum Schluss !! ARCSQRT_DISTR = IncludeModel("arcsqrt", RandomType, 0, 0, 1, NULL, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" checkOK, range_arcsqrt, PREF_AUX, true, 1, 1, (ext_bool) false, MON_MISMATCH); // to do: nicht mismatch, // sondern monotone im eindimensionalen kappanames("scale", REALSXP); RandomShape(0, structOK, init_arcsqrt, do_arcsqrt); addCov(arcsqrtD, arcsqrtDlog, arcsqrtDinverse, arcsqrtP, NULL, arcsqrtQ, arcsqrtR, NULL); DETERM_DISTR = IncludeModel("determ", RandomType, 0, 0, 1, kappa_determ, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_determ, range_determ, PREF_AUX, false, SUBMODEL_DEP, INFDIM-1, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("mean", REALSXP); RandomShape(INFTY, structOK, init_determ, do_determ); addCov(determD, determDlog, determDinverse, determP, determP2sided, determQ, determR, determR2sided); DISTRIBUTION = // FREEVARIABLE vorhanden. Muss extra in SpecialRMmodel.R // definiert und nicht ueber generatemodels.R IncludeModel("distr", RandomType, 0, 0, 16, kappa_distr, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_distr, range_distr, PREF_AUX, true, PARAM_DEP, INFDIM-1, (ext_bool) false, MON_MISMATCH); kappanames("name", STRSXP, "nrow", INTSXP, "ncol", INTSXP, "ddistr", LANGSXP, "pdistr", LANGSXP, "qdistr", LANGSXP, "rdistr", LANGSXP, "envir", ENVSXP, FREEVARIABLE, REALSXP, // wird nie verwendet -- Puffer fuer // einfachen Algorithmus FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP, FREEVARIABLE, REALSXP//, FREEVARIABLE, REALSXP ); // 7 free ones are remaining ! change_sortof(DISTR_DX, IGNOREPARAM); change_sortof(DISTR_PX, IGNOREPARAM); change_sortof(DISTR_QX, IGNOREPARAM); change_sortof(DISTR_RX, IGNOREPARAM); RandomShape(0, structOK, init_distr, do_distr_do); addCov(distrD, distrDlog, distrDinverse, distrP, distrP2sided, distrQ, distrR, distrR2sided); GAUSS_DISTR = // 139 IncludeModel("normal", RandomType, 0, 0, 3, kappa_gauss_distr, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_gauss_distr, range_gauss_distr, PREF_AUX, false, PARAM_DEP, INFDIM-1, (ext_bool) false, MON_MISMATCH); nickname("gauss"); kappanames("mu", REALSXP, "sd", REALSXP, "log", INTSXP); RandomShape(INFTY, structOK, init_gauss_distr, do_gauss_distr); addCov(gaussD, gaussDlog, gaussDinverse, gaussP, gaussP2sided, gaussQ, gaussR, gaussR2sided); SET_DISTR = // nur Handling von Parametern von shape nach pts IncludeModel("setDistr", RandomType, 1, 1, 1, NULL, DOMAIN_MISMATCH, ISO_MISMATCH, check_setParam, range_setParam, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); subnames("to"); kappanames("performDo", INTSXP); RandomShape(INFTY, structOK, init_setParam, do_setParam); addCov(setParamD, setParamDlog, setParamDinverse, setParamP, setParamP2sided, setParamQ, setParamR, setParamR2sided); LOC = IncludeModel("loc", RandomType, 1, 1, 3, kappa_loc, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_loc, range_loc, PREF_AUX, false, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("mu", REALSXP, "scale", REALSXP, "pow", REALSXP); RandomShape(INFTY, structOK, init_loc, do_loc); addCov(locD, locDlog, locDinverse, locP, locP2sided, locQ, locR, locR2sided); MCMC = IncludeModel("mcmc", RandomType, 1, 1, 6, kappa_mcmc, // ACHTUNG! Model kann auch ueber cov->q uebergeben werden. // dies vereinfacht die Verwendung von zufaelligen // Huetchen, da keine Parameter kopiert werden // muesen, sondern direkt auf das Huetchen zugegriffen // DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_mcmc, range_mcmc, PREF_AUX, false, PARAM_DEP, INFDIM-1, (ext_bool) true, MON_MISMATCH); kappanames(distr[RECT_MCMC_N], INTSXP, "sigma", REALSXP, "normed", INTSXP, "maxdensity", REALSXP, "rand.loc", INTSXP, "gibbs", INTSXP); RandomShape(INFTY, structOK, init_mcmc, do_mcmc); addCov(mcmcD, mcmcDlog, mcmcDinverse, mcmcP, mcmcP2sided, mcmcQ, mcmcR, mcmcR2sided); RECTANGULAR = IncludeModel("rectangular", RandomType, 1, 1, 11, NULL, // ACHTUNG! Model kann auch ueber cov->q uebergeben werden. // dies vereinfacht die Verwendung von zufaelligen // Huetchen, da keine Parameter kopiert werden // muesen, sondern direkt auf das Huetchen zugegriffen // DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_rectangular, range_rectangular, PREF_AUX, false, PARAM_DEP, INFDIM-1, (ext_bool) true, MON_MISMATCH); kappanames(distr[RECT_SAFETY], REALSXP, distr[RECT_MINSTEPLENGTH], REALSXP, distr[RECT_MAXSTEPS], INTSXP, distr[RECT_PARTS], INTSXP, distr[RECT_MAXIT], INTSXP, distr[RECT_INNERMIN], REALSXP, distr[RECT_OUTERMAX], REALSXP, distr[RECT_MCMC_N], INTSXP, "normed", INTSXP, "approx", INTSXP, "onesided", INTSXP ); RandomShape(INFTY, structOK, init_rectangular, do_rectangular); addCov(rectangularD, rectangularDlog, rectangularDinverse, rectangularP, rectangularP2sided, rectangularQ, rectangularR, rectangularR2sided); SCALESPHERICAL = IncludeModel("spheric", RandomType, 0, 0, 3, NULL, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_RRspheric, range_RRspheric, PREF_AUX, false, 1, 1, (ext_bool) true, MON_MISMATCH); kappanames("spacedim", INTSXP, "balldim", INTSXP, "R", REALSXP); RandomShape(INFTY, structOK, init_RRspheric, do_RRspheric); addCov(sphericD, sphericDlog, sphericDinverse, sphericP, NULL, sphericQ, sphericR, NULL); UNIF = IncludeModel("unif", RandomType, 0, 0, 3, kappa_unif, DOMAIN_MISMATCH, ISO_MISMATCH, // set to "cart sys" check_unif, range_unif, PREF_AUX, false, PARAM_DEP, INFDIM-1, (ext_bool) true, MON_MISMATCH); kappanames("min", REALSXP, "max", REALSXP, "normed", INTSXP); RandomShape(INFTY, structOK, init_unif, do_unif); addCov(unifD, unifDlog, unifDinverse, unifP, unifP2sided, unifQ, unifR, unifR2sided); // ----------------------------- // shape + locations // they *take* all very detailed frames like SmithType and pass // also their specific type to the submodel, in general // storage always pgs_storage !! MCMC_PGS = IncludeModel("MCMC_PGS", PointShapeType, 2, 2, 5, NULL, XONLY, CARTESIAN_COORD, check_mcmc_pgs, range_mcmc_pgs, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); // kappas must be identical to Zhou kappanames("density.ratio", REALSXP, // stemming from gauss "flat", INTSXP, "infinitely_small", INTSXP, "normed", INTSXP, "mcmc_n", INTSXP); subnames("shape", "loc"); addlogCov(logZhou); RandomShape(SUBMODEL_DEP, struct_mcmc_pgs, init_mcmc_pgs, do_mcmc_pgs, do_random_failed, true, true, false); ZHOU = IncludeModel("zhou", PointShapeType, 2, 2, 5, NULL, XONLY, CARTESIAN_COORD, check_Zhou, range_Zhou, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("density.ratio", REALSXP, // stemming from gauss "flat", INTSXP, "infinitely_small", INTSXP, "normed", INTSXP, "isotropic", INTSXP ); subnames("shape", "loc"); addCov(Zhou, NULL, NULL); addlogCov(logZhou); RandomShape(SUBMODEL_DEP, struct_Zhou, init_Zhou, do_Zhou, do_random_failed, true, true, false); BALLANI = IncludeModel("ballani", PointShapeType, 2, 2, 5, NULL, XONLY, CARTESIAN_COORD, check_Ballani, range_Ballani, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("density.ratio", REALSXP, // unklar welche parameter ueberhaupt gebraucht werden. "flat", INTSXP, "infinitely_small", INTSXP, "normed", INTSXP, "isotropic", INTSXP ); subnames("shape", "loc"); addCov(Ballani, NULL, NULL); addlogCov(logBallani); RandomShape(SUBMODEL_DEP, struct_Ballani, init_Ballani, do_Ballani, do_random_failed, true, true, false); STANDARD_SHAPE = IncludeModel("standardShape", PointShapeType, 1, 2, 0, NULL, XONLY, CARTESIAN_COORD, check_standard_shape, NULL, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); subnames("shape"); addCov(standard_shape, NULL, NULL); addlogCov(logstandard_shape); RandomShape(SUBMODEL_DEP, struct_standard_shape, init_standard_shape, do_standard_shape, do_random_failed, true, true, false); pref_type pmppp = {0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0, 10, 5}; // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any MPPPLUS = IncludeModel("++", PointShapeType, 1, MAXSUB, 1, kappamppplus, PREVMODEL_D, PREVMODEL_I, // CARTESIAN_COORD, checkmppplus, rangempplus, pmppp, false, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("mppplus"); kappanames("p", REALSXP); addCov(mppplus, NULL, NULL); STATIONARY_SHAPE = IncludeModel("statShape", PointShapeType, 1, 1, 0, NULL, XONLY, CARTESIAN_COORD, check_stationary_shape, NULL, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); subnames("shape"); addCov(stationary_shape, NULL, NULL); addlogCov(logstationary_shape); RandomShape(SUBMODEL_DEP, struct_stationary_shape, init_stationary_shape, do_stationary_shape, do_random_failed, true, true, false); COVFCTN = // ALWAYS FIRST WITHIN FUNCTION WITHOUT GENUINE I NIT IncludeModel("Cov", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_cov, NULL, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("cov"); addCov(Cov, NULL, NULL); RandomShape(2, struct_cov, init_cov, do_failed); COVMATRIX = IncludeModel("CovMatrix", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, //UNREDUCED,ISOTROPIC dependening on whether // distances are givenXONLY, UNREDUCED, check_covmatrix, NULL, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("covmatrix"); addCov(CovMatrix, NULL, NULL); RandomShape(struct_cov); IncludeModel("Dummy", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_dummy, NULL, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("dummy"); addCov(Dummy, NULL, NULL); RandomShape(struct_dummy); RFGET = IncludeModel("get", InterfaceType, 1, 1, 2, NULL, XONLY, UNREDUCED, check_RFget, range_RFget, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("up", INTSXP, "register", INTSXP); addCov(RFget, NULL, NULL); RandomShape(struct_RFget); IncludeModel("Fctn", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_fctn, NULL, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("fctn"); addCov(Fctn, NULL, NULL); RandomShape(structOK); IncludeModel("Distr", InterfaceType, 1, 1, 5, kappa_EvalDistr, XONLY, UNREDUCED, check_EvalDistr, range_EvalDistr, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("distr"); kappanames("x", REALSXP, "q", REALSXP, "p", REALSXP, "n", REALSXP, "dim", INTSXP); addCov(EvalDistr, NULL, NULL); RandomShape(struct_EvalDistr); LIKELIHOOD_CALL = IncludeModel("loglikelihood", InterfaceType, 1, 1, 4, kappalikelihood, XONLY, UNREDUCED, check_likelihood, range_likelihood, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("data", LISTOF + REALSXP, "estimate_variance", INTSXP, "betas_separate", INTSXP, "ignore_trend", INTSXP); addCov(likelihood, NULL, NULL); RandomShape(struct_likelihood); LINEARPART_CALL = IncludeModel("linearpart", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_linearpart, NULL, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); addCov(linearpart, NULL, NULL); RandomShape(struct_linearpart); PREDICT_CALL = IncludeModel("predict", InterfaceType, 0, 1, 1, NULL, XONLY, UNREDUCED, check_predict, range_predict, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); kappanames("register", INTSXP); addCov(predict, NULL, NULL); RandomShape(struct_predict); IncludeModel("Pseudovariogram", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_cov, NULL, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("pseudovariogram"); addCov(Pseudovariogram, NULL, NULL); RandomShape(struct_variogram); VARIOGRAM_CALL = // ALWAYS WITHIN FUNCTION WITHOUT GENUINE I NIT IncludeModel("Variogram", InterfaceType, 1, 1, 0, NULL, XONLY, UNREDUCED, check_vario, NULL, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("variogram"); addCov(Variogram, NULL, NULL); RandomShape(struct_variogram); SIMULATE = IncludeModel("Simulate", InterfaceType, 1, 1, 3, NULL, XONLY, UNREDUCED, check_simulate, range_simulate, PREF_AUX, INTERN_SHOW, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("simulate"); kappanames("checkonly", INTSXP, "setseed", LANGSXP, "env", ENVSXP); addCov(simulate, NULL, NULL); RandomShape(struct_simulate); /* DENSITY = IncludeModel("Density", InterfaceType, 1, 1, 3, NULL, XONLY, UNREDUCED, check_density, range_density, PREF_AUX, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_MISMATCH); nickname("density"); kappanames("log", INTSXP, "setseed", LANGSXP, "env", ENVSXP); addCov(density, NULL, NULL); RandomShape(struct_density); */ // ---------------------------- // processes // CE CO CI TBM Sp di sq Ma av n mpp Hy spf any DOLLAR_PROC = IncludeModel("$proc", ProcessType, 1, 1, 5, kappaS, // kappadollar, XONLY, UNREDUCED, checkS, rangeS, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); // do not change Order!! addSpecific(DOLLAR); RandomShape(2, structSproc, initSproc, doSproc, true, true, true); AddVariant(GaussMethodType, UNREDUCED); PLUS_PROC = IncludeModel("plusproc", ProcessType, 1, MAXSUB, 0, NULL, XONLY, UNREDUCED, checkplusproc, NULL, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addSpecific(PLUS); RandomShape(2, structplusproc, initplusproc, doplusproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); // PROD_PROC = IncludeModel("prodproc", ProcessType, 1, 1, 0, NULL, XONLY, UNREDUCED, checkprodproc, NULL, PREF_ALL, true, PARAM_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); addSpecific(PROD); RandomShape(2, structprodproc, initprodproc, doprodproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); IncludeModel("trafoproc", ProcessType, 1, 1, 1, kappatrafo, XONLY, UNREDUCED, checktrafoproc, rangetrafo, PREF_ALL, true, PARAM_DEP, INFDIM-1, (ext_bool) false, NOT_MONOTONE); addSpecific(TRAFO); RandomShape(2, structtrafoproc, inittrafoproc, dotrafoproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); MPPPLUS_PROC = IncludeModel("mppplusproc", ProcessType, 1, MAXSUB, 1, kappamppplus, XONLY, UNREDUCED, checkmppplus, rangempplus, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); nickname("mppplus"); // addSpecific(MPPPLUS); kappanames("p", REALSXP); RandomShape(2, struct_mppplus, init_mppplus, do_mppplus, true, true, true); MULT_PROC = IncludeModel("multproc", ProcessType, 1, MAXSUB, 1, NULL, XONLY, UNREDUCED, checkmultproc, rangemultproc, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addSpecific(MULT); kappanames("multicopies", INTSXP); RandomShape(2, structmultproc, initmultproc, domultproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); M_PROC = IncludeModel("matrixproc", ProcessType, 1, MAXSUB, 2, kappaM, XONLY, UNREDUCED, checkM, rangeM, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addSpecific(MATRIX); RandomShape(2, structMproc, initMproc, doMproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); VAR2COV_PROC = IncludeModel("covproc", ProcessType, 1, MAXSUB, 2, NULL, XONLY, UNREDUCED, checkvar2covproc, rangevariogram2cov, PREF_ALL, true, SUBMODEL_DEP, SUBMODEL_DEP, (ext_bool) SUBMODEL_DEP, MON_SUB_DEP); addSpecific(VARIOGRAM2COV); RandomShape(2, structvar2covproc, initvar2covproc, dovar2covproc, false, false, true); AddVariant(GaussMethodType, UNREDUCED); TREND_PROC = IncludeModel(METHOD_NAMES[Trendproc], ProcessType, 0, 1, 1, kappatrend, XONLY, UNREDUCED, checkTrendproc, rangetrend, PREF_TREND, false, SUBMODEL_DEP, INFDIM-1, (ext_bool) false, MON_MISMATCH); addSpecific(TREND); RandomShape(2, init_Trendproc, do_Trendproc); AddVariant(GaussMethodType, UNREDUCED); //////////// STANDARD PROCESSES //////////////// AVERAGE_USER = IncludeModel(METHOD_NAMES[Average], GaussMethodType, 1, 2, 3, kappaGProc, XONLY, UNREDUCED, check_randomcoin, range_randomcoin, PREF_NOTHING, false, SCALAR, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); subnames("phi", "shape"); kappanames("boxcox", REALSXP, "intensity", REALSXP, "method", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); // change_typeof(RANDOMCOIN_INTENSITY, RandomType); // addCov(coin, NULL, NULL, coinInverse); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); RANDOMCOIN_USER = CopyModel(METHOD_NAMES[RandomCoin], AVERAGE_USER); AVERAGE_INTERN = CopyModel("averageIntern", AVERAGE_USER); addSpecific(RANDOMCOIN_USER, false); addSpecific(AVERAGE_USER, false); // see gauss.cc for the use of Specific! RandomShape(2, struct_randomcoin, init_randomcoin, dompp, true, true, false); CIRCEMBED = // und die anderen fehlen auch noch !! IncludeModel(METHOD_NAMES[CircEmbed], GaussMethodType, 1, 1, 13, kappa_ce, XONLY, UNREDUCED, check_ce, range_ce, PREF_NOTHING, false, SUBMODEL_DEP, MAXCEDIM, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, CE[CE_FORCE - COMMON_GAUSS - 1], INTSXP, CE[CE_MMIN - COMMON_GAUSS - 1], REALSXP, CE[CE_STRATEGY - COMMON_GAUSS - 1], INTSXP, CE[CE_MAXGB - COMMON_GAUSS - 1], REALSXP, CE[CE_MAXMEM - COMMON_GAUSS - 1], INTSXP, CE[CE_TOLIM - COMMON_GAUSS - 1], REALSXP, CE[CE_TOLRE - COMMON_GAUSS - 1], REALSXP, CE[CE_TRIALS - COMMON_GAUSS - 1], INTSXP, CE[CE_USEPRIMES - COMMON_GAUSS - 1], INTSXP, CE[CE_DEPENDENT - COMMON_GAUSS - 1], INTSXP, CE[CE_APPROXSTEP - COMMON_GAUSS - 1], REALSXP, CE[CE_APPROXMAXGRID - COMMON_GAUSS - 1], INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_ce_approx, init_ce_approx, do_ce_approx); CE_CUTOFFPROC_USER = IncludeModel(METHOD_NAMES[CircEmbedCutoff], GaussMethodType, 1, 1, 15, kappa_localproc, XONLY, UNREDUCED, check_local_proc, range_co_proc, PREF_NOTHING, false, SCALAR, MAXCEDIM, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, CE[CE_FORCE - COMMON_GAUSS - 1], INTSXP, CE[CE_MMIN - COMMON_GAUSS - 1], REALSXP, CE[CE_STRATEGY - COMMON_GAUSS - 1], INTSXP, CE[CE_MAXGB - COMMON_GAUSS - 1], REALSXP, CE[CE_MAXMEM - COMMON_GAUSS - 1], INTSXP, CE[CE_TOLIM - COMMON_GAUSS - 1], REALSXP, CE[CE_TOLRE - COMMON_GAUSS - 1], REALSXP, CE[CE_TRIALS - COMMON_GAUSS - 1], INTSXP, CE[CE_USEPRIMES - COMMON_GAUSS - 1], INTSXP, CE[CE_DEPENDENT - COMMON_GAUSS - 1], INTSXP, CE[CE_APPROXSTEP - COMMON_GAUSS - 1], REALSXP, CE[CE_APPROXMAXGRID - COMMON_GAUSS - 1], INTSXP, "diameter", REALSXP, "a", REALSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); CE_CUTOFFPROC_INTERN = CopyModel("cutoffIntern", CE_CUTOFFPROC_USER); addSpecific(CE_CUTOFFPROC_USER, false); RandomShape(2, struct_ce_approx, init_ce_approx, do_ce_approx); CE_INTRINPROC_USER = IncludeModel(METHOD_NAMES[CircEmbedIntrinsic], GaussMethodType, 1, 1, 15, kappa_localproc, XONLY, UNREDUCED, check_local_proc, range_intrinCE, PREF_NOTHING, false, SCALAR, MAXCEDIM, (ext_bool) false, MON_MISMATCH); nickname(METHOD_NAMES[CircEmbedIntrinsic]); kappanames("boxcox", REALSXP, CE[CE_FORCE - COMMON_GAUSS - 1], INTSXP, CE[CE_MMIN - COMMON_GAUSS - 1], REALSXP, CE[CE_STRATEGY - COMMON_GAUSS - 1], INTSXP, CE[CE_MAXGB - COMMON_GAUSS - 1], REALSXP, CE[CE_MAXMEM - COMMON_GAUSS - 1], INTSXP, CE[CE_TOLIM - COMMON_GAUSS - 1], REALSXP, CE[CE_TOLRE - COMMON_GAUSS - 1], REALSXP, CE[CE_TRIALS - COMMON_GAUSS - 1], INTSXP, CE[CE_USEPRIMES - COMMON_GAUSS - 1], INTSXP, CE[CE_DEPENDENT - COMMON_GAUSS - 1], INTSXP, CE[CE_APPROXSTEP - COMMON_GAUSS - 1], REALSXP, CE[CE_APPROXMAXGRID - COMMON_GAUSS - 1], INTSXP, "diameter",REALSXP, "rawR", REALSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); CE_INTRINPROC_INTERN = CopyModel("intrinsIntern", CE_INTRINPROC_USER); addSpecific(CE_INTRINPROC_USER, false); RandomShape(2, struct_ce_approx, init_ce_approx, do_ce_approx); DIRECT = IncludeModel(METHOD_NAMES[Direct], GaussMethodType, 1, 1, 1, kappaGProc, XONLY, UNREDUCED, check_directGauss, range_direct, PREF_NOTHING, false, SUBMODEL_DEP, INFDIM-1, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, init_directGauss, do_directGauss); HYPERPLANE_USER = IncludeModel(METHOD_NAMES[Hyperplane], GaussMethodType, 1, 1, 6, kappaGProc, XONLY, UNREDUCED, check_hyperplane, range_hyperplane, PREF_NOTHING, false, SCALAR, 2, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, "superpos", INTSXP, "maxlines", INTSXP, "mar_distr", INTSXP, "mar_param", REALSXP, "additive", INTSXP); // addCov(IdStat, NULL, NULL, IdInverse); // addCov(IdNonStat); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); HYPERPLANE_INTERN = CopyModel("hyperIntern", HYPERPLANE_USER, check_hyperplane_intern); addSpecific(HYPERPLANE_USER, false); RandomShape(2, struct_hyperplane, init_hyperplane, do_hyperplane); NUGGET_USER = IncludeModel(METHOD_NAMES[Nugget], GaussMethodType, 1, 1, 3, kappaGProc, XONLY, UNREDUCED, check_nugget_proc, range_nugget_proc, PREF_NOTHING, false, PREVMODEL_DEP, INFDIM, (ext_bool) true, MON_MISMATCH); kappanames("boxcox", REALSXP,"tol", REALSXP, "vdim", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); NUGGET_INTERN = CopyModel("nuggetIntern", NUGGET_USER); addSpecific(NUGGET_USER, false); RandomShape(2, struct_nugget, init_nugget, do_nugget); /* see simu.cc, CMbuild for special treatment of nugget when users choice is given */ /* cf. convert.R, PrepareModel, near end of function */ SEQUENTIAL = IncludeModel(METHOD_NAMES[Sequential], GaussMethodType, 1, 1, 3, kappaGProc, XONLY, UNREDUCED, check_sequential, range_sequential, PREF_NOTHING, false, SCALAR, INFDIM-1, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, "back_steps", INTSXP, "initial", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, init_sequential, do_sequential); SPECTRAL_PROC_USER = IncludeModel(METHOD_NAMES[SpectralTBM], GaussMethodType, 1, 1, 5, kappaGProc, XONLY, UNREDUCED, check_spectral, range_spectral, PREF_NOTHING, false, SCALAR, MAXTBMSPDIM, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP,"sp_lines", INTSXP, "sp_grid", INTSXP, "prop_factor", REALSXP, "sigma", REALSXP ); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); SPECTRAL_PROC_INTERN = CopyModel("spectralIntern", SPECTRAL_PROC_USER); addSpecific(SPECTRAL_PROC_USER, false); RandomShape(2, struct_spectral, init_spectral, do_spectral); SPECIFIC = IncludeModel(METHOD_NAMES[Specific], GaussMethodType, 1, 1, 1, kappaGProc, XONLY, UNREDUCED, check_specificGauss, range_specificGauss, PREF_NOTHING, false, SUBMODEL_DEP, MAXTBMSPDIM, (ext_bool) false, MON_MISMATCH); RandomShape(2, struct_specificGauss, init_specificGauss, do_specificGauss); kappanames("boxcox", REALSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); TBM_PROC_USER = IncludeModel(METHOD_NAMES[TBM], GaussMethodType, 1, 1, 9, tbm_kappasproc, XONLY, UNREDUCED, checktbmproc, rangetbmproc, PREF_NOTHING, false, PARAM_DEP, SUBMODEL_DEP, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, "fulldim", INTSXP, "reduceddim", INTSXP, "layers", INTSXP, "lines", INTSXP, "linessimufactor", REALSXP, "linesimustep", REALSXP, // "grid", INTSXP, "center", REALSXP, "points", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); change_sortof(TBM_LAYERS, ONLYRETURN); // NA will not be estimated RandomShape(2, struct_gaussmethod, init_gaussprocess, do_gaussprocess); TBM_PROC_INTERN = CopyModel("tbmIntern", TBM_PROC_USER); addSpecific(TBM_PROC_USER); RandomShape(2, struct_tbmproc, init_tbmproc, do_tbmproc); gaussmethod[CircEmbed] = CIRCEMBED; gaussmethod[CircEmbedCutoff]= CE_CUTOFFPROC_INTERN; gaussmethod[CircEmbedIntrinsic] = CE_INTRINPROC_INTERN; gaussmethod[TBM] = TBM_PROC_INTERN; gaussmethod[SpectralTBM] = SPECTRAL_PROC_INTERN; gaussmethod[Direct] = DIRECT; gaussmethod[Sequential] = SEQUENTIAL; gaussmethod[Trendproc] = TREND_PROC; gaussmethod[Average] = AVERAGE_INTERN; gaussmethod[Nugget] = NUGGET_INTERN; gaussmethod[RandomCoin] = AVERAGE_INTERN; gaussmethod[Hyperplane] = HYPERPLANE_INTERN; gaussmethod[Specific] = SPECIFIC; gaussmethod[Nothing] = gaussmethod[Forbidden] = MISMATCH; BRNORMED = IncludeModel("loggaussnormed", NormedProcessType, 1, 1, 5, kappabrnormed, XONLY, UNREDUCED, check_brnormed, range_brnormed, PREF_NOTHING, false, SUBMODEL_DEP, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); kappanames("prob", REALSXP, "optimize_p", INTSXP, "nth", INTSXP, "burn.in", INTSXP, "rejection", INTSXP ); subnames("variogram"); addlogCov(logZhou); //RandomShape(SUBMODEL_DEP, struct_brnormed, init_brnormed, // 2.2.19 // do_brnormed, do_random_failed, true, true, false); RandomShape(0, struct_brnormed, init_brnormed, do_brnormed, finalmaxstable); // non sub-gaussian processe BRORIGINAL_USER = IncludeModel("brorig", BrMethodType, 1, 2, 3, NULL, XONLY, UNREDUCED, checkBrownResnickProc, range_mpp, PREF_NOTHING, false, SCALAR, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP); subnames("phi", "tcf"); RandomShape(0, structBRuser, initBRuser, dompp, finalmaxstable); addlogD(loglikelihoodBR); BRORIGINAL_INTERN = CopyModel("brorigIntern", BRORIGINAL_USER, PointShapeType); make_internal(); nickname("brorig"); RandomShape(SUBMODEL_DEP, structBRintern, init_BRorig, do_BRorig); BRMIXED_USER = IncludeModel("brmixed", BrMethodType, 1, 2, 10, kappaBRmixed, XONLY, UNREDUCED, check_BRmixed, range_BRmixed, PREF_NOTHING, false, SUBMODEL_DEP, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP, "meshsize", REALSXP, "vertnumber", INTSXP, "optim_mixed", INTSXP, "optim_mixed_tol", REALSXP, "lambda", REALSXP, "areamat", REALSXP, "variobound", REALSXP); subnames("phi", "tcf"); RandomShape(0, structBRuser, initBRuser, dompp, finalmaxstable); addlogD(loglikelihoodBR); BRMIXED_INTERN = CopyModel("brmixedIntern", BRMIXED_USER, PointShapeType); make_internal(); nickname("brmixed"); RandomShape(SUBMODEL_DEP, structBRintern, init_BRmixed, do_BRmixed); BRSHIFTED_USER = IncludeModel("brshifted", BrMethodType, 1, 2, 3, NULL, XONLY, UNREDUCED, checkBrownResnickProc, range_mpp, PREF_NOTHING, false, SCALAR, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); subnames("phi", "tcf"); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP); RandomShape(0, structBRuser, initBRuser, dompp, finalmaxstable); addlogD(loglikelihoodBR); BRSHIFTED_INTERN = CopyModel("brshiftIntern", BRSHIFTED_USER, PointShapeType); make_internal(); nickname("brshif"); RandomShape(SUBMODEL_DEP, structBRintern, init_BRshifted, do_BRshifted); BROWNRESNICKPROC = IncludeModel("brownresnick", BrMethodType, // ProcessType 1, 2, 3, NULL, XONLY, UNREDUCED, checkBrownResnickProc, range_mpp, PREF_NOTHING, false, SCALAR, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); subnames("phi", "tcf"); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP); // addCov(BrownResnick, NULL, NULL); RandomShape(0, structBrownResnick, initBrownResnick, doBrownResnick, finaldoBrownResnick); addlogD(loglikelihoodBR); // distributions BINARYPROC = // direct an Gauss gekoppelt!! IncludeModel("binaryprocess", NormedProcessType, 1, 1, 3, kappa_binaryprocess, XONLY, UNREDUCED, checkbinaryprocess, rangebinaryprocess, PREF_NOTHING, false, SUBMODEL_DEP, INFDIM, (ext_bool) false, MON_MISMATCH); nickname( "bernoulli"); kappanames(INTERNAL_PARAM, REALSXP, "stationary_only", INTSXP, "threshold", REALSXP); //"p", REALSXP); RandomShape(INFTY, struct_binaryprocess, init_binaryprocess, do_binaryprocess); GAUSSPROC = // never change names. See fitgauss.R, for instance IncludeModel("gauss.process", GaussMethodType, // formerly Processtype 1, 1, 2, kappaGProc, XONLY, UNREDUCED, checkgaussprocess, rangegaussprocess, PREF_NOTHING, false, SUBMODEL_DEP, INFDIM, (ext_bool) false, MON_MISMATCH); nickname("gauss"); kappanames("boxcox", REALSXP, "stationary_only", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); change_sortof(GAUSSPROC_STATONLY, ONLYRETURN); // NA will not be estimated RandomShape(2, struct_gaussprocess, init_gaussprocess, do_gaussprocess); addlogD(gaussprocessDlog); POISSONPROC = IncludeModel("poisson", PoissonType, 1, 1, 1, NULL, XONLY, UNREDUCED, check_poisson, range_poisson, PREF_NOTHING, false, SUBMODEL_DEP, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); kappanames("intensity", REALSXP); RandomShape(0, struct_poisson, init_poisson, dompp); SCHLATHERPROC = IncludeModel("extremalgauss", SchlatherType, 1, 2, 3, NULL, XONLY, UNREDUCED, check_schlather, range_mpp, PREF_NOTHING, false, SCALAR, INFDIM, (ext_bool) false, MON_MISMATCH); nickname("schlather"); subnames("phi", "tcf"); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP); addCov(extremalgaussian, NULL, NULL); RandomShape(0, struct_schlather, init_mpp, dompp, finalmaxstable); addlogD(loglikelihoodSchlather); EXTREMALTPROC = IncludeModel("extremalt", SchlatherType, 1, 1, 4, NULL, XONLY, UNREDUCED, check_schlather, range_opitz, PREF_NOTHING, false, SCALAR, INFDIM, (ext_bool) false, MON_MISMATCH); nickname("opitz"); subnames("phi"); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP, "alpha", REALSXP); addCov(extremalgaussian, NULL, NULL); RandomShape(0, struct_schlather, init_opitzprocess, dompp, finalmaxstable); addlogD(loglikelihoodSchlather); SMITHPROC = IncludeModel("smith", SmithType, 1, 2, 3, NULL, XONLY, UNREDUCED, check_smith, range_mpp, PREF_NOTHING, false, SCALAR, MAXMPPDIM, (ext_bool) false, MON_MISMATCH); subnames("shape", "tcf"); kappanames("xi", REALSXP, "mu", REALSXP, "s", REALSXP //, "intensity", REALSXP ); // change_typeof(SMITH_INTENSITY, RandomType); RandomShape(0, struct_smith, init_mpp, dompp, finalmaxstable); CHI2PROC = IncludeModel("chi2", ProcessType, 1, 1, 2, kappaGProc, XONLY, UNREDUCED, checkchisqprocess, rangechisqprocess, PREF_NOTHING, false, SUBMODEL_DEP, INFDIM, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, "f", INTSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(0, struct_chisqprocess, init_chisqprocess, do_chisqprocess); TPROC = IncludeModel("t", ProcessType, 1, 1, 2, kappaGProc, XONLY, UNREDUCED, checkchisqprocess, rangetprocess, PREF_NOTHING, false, SUBMODEL_DEP, INFDIM, (ext_bool) false, MON_MISMATCH); kappanames("boxcox", REALSXP, "nu", REALSXP); change_sortof(GAUSS_BOXCOX, ANYPARAM); RandomShape(0, struct_chisqprocess, init_chisqprocess, do_tprocess); } RandomFields/src/D.H.cc0000644000176200001440000002157713437301605014306 0ustar liggesusers/* Authors Martin Schlather, schlather@math.uni-mannheim.de calculation of the Hurst coefficient and the fractal dimension of the graph of a random field Copyright (C) 2002 - 2017 Martin Schlather, This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "RF.h" SEXP boxcounting(SEXP Z, // data SEXP LX, // basic length of data SEXP Repet, // "independent" repetitions of data SEXP Factor, // rescalin of data values by factor SEXP Eps // box lengths ) { // in sum, the boxcounting result for the first lx data values is given // according to the box lengths given by eps; then the boxes are counted // for the next lx data values, etc. Hence, sum must have dimension int *eps = INTEGER(Eps), leps = length(Eps), repet = INTEGER(Repet)[0], lx = INTEGER(LX)[0]; long i, k, j, e, r, lastbox, s, // 0 to leps * repet -1 truelx = 2 + lx, total = repet * truelx; double zz, min, max, f, *sum, factor = REAL(Factor)[0], *z = REAL(Z); SEXP Sum; PROTECT(Sum = allocVector(REALSXP, leps * repet)); sum = REAL(Sum); // boxcounting expects that the first and the last values are repeated // in the first dimension, see D.H.R; accordingly the total length in // the first direction is increased by 2: for (s=r=0; r max) max = z[i]; assert(i <= r + lx + 1); if ((zz = 0.5 * (z[i-1] + z[i])) < min) min = zz; else if (zz > max) max = zz; f = factor / (double) e; sum[s] += FLOOR(max * f) - FLOOR(min * f) + 1.0; } } } UNPROTECT(1); return Sum; } SEXP periodogram(SEXP Dat, // data SEXP Len, // basic length of data SEXP Repet, // # of "independent" repetitions SEXP FFTM, // fftm[0] >=1 not >=1 (R indexing assumed) // interval of the vector given by fft of part SEXP Part, // not the basic length but only a part is // transformed SEXP Shift // part is then shifted by shift until end of // vector is reached; fft values are averaged // over all these parts ){ int *fftm = INTEGER(FFTM), part = INTEGER(Part)[0]; assert((fftm[0]>=1) && (fftm[1] <=part) && (fftm[1] >= fftm[0])); long seg_dat, k, j, total_seg, segment_r, repet = INTEGER(Repet)[0], start_k = 2 * (fftm[0] - 1), // of complex numbers end_k = 2 * (fftm[1] - 1), // of complex numbers segm_l, r, delta_l = fftm[1] - fftm[0] + 1, end_l = delta_l * repet, err = ERRORFAILED, len = INTEGER(Len)[0], lenMpart = len - part, shift = INTEGER(Shift)[0]; assert(lenMpart >= 0); assert(shift>=1); double taper_fact = SQRT( 2.0 / (3.0 * ((double) part + 1.0)) ), cos_factor = 2.0 * PI / ((double) part + 1.0), *compl_number = NULL, *taper = NULL, *lambda = NULL, n_inv = 1.0 / (double) ((int) (1.0 + lenMpart / (double) shift)), *dat = REAL(Dat), factor = LOG(2.0 * PI * len) ; FFT_storage FFT; SEXP Lambda; PROTECT(Lambda = allocVector(REALSXP, end_l)); lambda = REAL(Lambda); for (j=0; j 1); double var, a, b, residual, Yt, realm, sumt, meanY, t, VarMeth_old, VarMeth_mean, VarMeth_var, delta, realnbox, *lvar, *dat = REAL(Dat); SEXP Lvar; // ## rbind(l.varmeth.var, l.dfa.var) 2 * (repet * ldfa) PROTECT(Lvar = allocMatrix(REALSXP, 2, ldfa * repet)); lvar = REAL(Lvar); for (e = r = 0; r < total; r += lx, e+=ldfa) { last = r + lx; for (j=r+1; j 1) { VarMeth_mean = dat[ex - 1] / (realnbox); VarMeth_old = 0; VarMeth_var = 0; for (j=r+m-1; j max) max = dat[idx]; } count[cb] += max - min; } count[cb] = LOG(count[cb] / (double) epsilon); } // b } // r UNPROTECT(1); return Count; } RandomFields/src/avltr_modified.cc0000644000176200001440000010015513437301605016713 0ustar liggesusers/* libavl - manipulates AVL trees. Copyright (C) 1998, 1999 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The author may be contacted at on the Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA through more mundane means. */ /* This is file avltr.c in libavl. */ /* Martin Schlather: 21 October, 2011, This file has been file avltr.cc in libavl. The #include "avltr.h" has been changed to "avltr_modified.h". Further #include "basic.h" is added, fprint has been replaced by error, exit has been outcommented print has been replaced by Rprint. The above stated GNU General Public License to its full extend is still valid. */ #if HAVE_CONFIG_H #include #endif #if SELF_TEST #include #endif #include #include #include "basic.h" //#include "avltr.h" #include "avltr_modified.h" /* Tag types. */ #define PLUS +1 #define MINUS -1 #define LEFT -1 #define RIGHT +1 #define CENTER 0 #if !__GCC__ && !defined (inline) #define inline #endif void print_structure (avltr_tree *tree, avltr_node *node, int level); #if __GNUC__ >= 2 #define unused __attribute__ ((unused)) #else #define unused #endif #ifdef HAVE_Xmalloc void *xmalloc (size_t); #else /* !HAVE_Xmalloc */ /* Allocates SIZE bytes of space using 'malloc'. Aborts if out of memory. */ void *xmalloc (size_t size) { void *vp; if (size == 0) return NULL; vp = malloc (size); assert (vp != NULL); if (vp == NULL) { RFERROR("virtual memory exhausted\n"); // exit (EXIT_FAILURE); } return vp; } #endif /* !HAVE_Xmalloc */ /* Creates an AVL tree in arena OWNER (which can be NULL). The arena is owned by the caller, not by the AVL tree. CMP is a order function for the data to be stored in the tree. PARAM is arbitrary data that becomes an argument to the comparison function. */ avltr_tree * avltr_create (avl_comparison_func cmp, int *param) { avltr_tree *tree; assert (cmp != NULL); tree = (avltr_tree *) xmalloc (sizeof (avltr_tree)); tree->root.link[0] = NULL; tree->root.link[1] = &tree->root; tree->root.rtag = PLUS; tree->cmp = cmp; tree->count = 0; tree->param = param; return tree; } /* Destroy tree TREE. Function FREE_FUNC is called for every node in the tree as it is destroyed. No effect if the tree has an arena owner and free_func is NULL. The caller owns the arena and must destroy it itself. Do not attempt to reuse the tree after it has been freed. Create a new one. */ void avltr_destroy (avltr_tree *tree, avl_node_func free_func) { assert (tree != NULL); if (tree->root.link[0] != &tree->root) { /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13 (postorder traversal), further modified for right-threaded trees. */ /* T1. */ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */ int ap = 0; /* Stack A: height. */ avltr_node *p = tree->root.link[0]; for (;;) { /* T2. */ while (p != NULL) { /* T3. */ ab[ap] = 0; an[ap++] = p; p = p->link[0]; } /* T4. */ for (;;) { if (ap == 0) goto done; p = an[--ap]; if (ab[ap] == 0) { ab[ap++] = RIGHT; if (p->rtag == MINUS) continue; p = p->link[1]; break; } if (free_func) free_func (p->data, tree->param); FREE(p); } } } done: FREE(tree); } /* avltr_destroy() with FREE_FUNC hardcoded as FREE(). */ void avltr_free (avltr_tree *tree) { avltr_destroy (tree, (avl_node_func) free); } /* Return the number of nodes in TREE. */ int avltr_count (avltr_tree *tree) { assert (tree != NULL); return tree->count; } /* Copy the contents of TREE to a new tree in arena OWNER. If COPY is non-NULL, then each data item is passed to function COPY, and the return values are inserted into the new tree; otherwise, the items are copied verbatim from the old tree to the new tree. Returns the new tree. */ avltr_tree * avltr_copy (avltr_tree *tree, avl_copy_func copy) { /* Knuth's Algorithm 2.3.1C (copying a binary tree). Additionally uses Algorithm 2.3.1I (insertion into a threaded binary tree) and Algorithm 2.3.1 exercise 17 (preorder successor in threaded binary tree). */ avltr_tree *new_tree; avltr_node *p; avltr_node *q; assert (tree != NULL); new_tree = avltr_create (tree->cmp, tree->param); new_tree->count = tree->count; p = &tree->root; if (p->link[0] == p) return new_tree; q = &new_tree->root; for (;;) { /* C4. This is Algorithm 2.3.1 exercise 23 for insertion to the left in a right-threaded binary tree. */ if (p->link[0] != NULL) { avltr_node *r = (avltr_node *) xmalloc (sizeof (avltr_node)); q->link[0] = r; r->link[0] = NULL; r->link[1] = q; r->rtag = MINUS; } /* C5: Find preorder successors of P and Q. This is Algorithm 2.3.1 exercise 17 but applies its actions to Q as well as P. */ if (p->link[0] != NULL) { p = p->link[0]; q = q->link[0]; } else { while (p->rtag == MINUS) { p = p->link[1]; q = q->link[1]; } p = p->link[1]; q = q->link[1]; } /* C6. */ if (p == &tree->root) { assert (q == &new_tree->root); return new_tree; } /* C2. This is Algorithm 2.3.1 exercise 23 for insertion to the right in a right-threaded binary tree. */ if (p->rtag == PLUS) { avltr_node *r = (avltr_node *) xmalloc (sizeof (avltr_node)); r->link[1] = q->link[1]; r->rtag = q->rtag; q->link[1] = r; q->rtag = PLUS; r->link[0] = NULL; } /* C3. */ q->bal = p->bal; if (copy == NULL) q->data = p->data; else q->data = copy (p->data, tree->param); } } /* Threads the unthreaded AVL tree TREE in-place, and returns TREE cast to avltr_tree *. */ avltr_tree * avltr_thread (struct avl_tree *_tree) { /* Uses Knuth's Algorithm 2.3.1 exercise 30 (thread an unthreaded tree, with Algorithm 2.3.1T (inorder traversal) for computing Q$. */ avltr_tree *tree = (avltr_tree *) _tree; /* Algorithm T's variables. */ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */ avltr_node **ap; /* Stack A: stack pointer. */ avltr_node *tp; /* P. */ /* Algorithm L's variables. */ avltr_node *p, *q; assert (tree != NULL); /* T1. */ ap = an; tp = tree->root.link[0]; /* L1. */ q = &tree->root; q->link[1] = q; for (;;) { /* L2. */ { /* T2. */ while (tp != NULL) { /* T3. */ *ap++ = tp; tp = tp->link[0]; } /* T4. Modified to visit HEAD after fully traversing the tree. */ if (ap == an) tp = &tree->root; else tp = *--ap; /* T5: Visit P. */ p = tp; } /* L3. */ if (q->link[1] == NULL) { q->link[1] = p; q->rtag = MINUS; } else q->rtag = PLUS; /* L4. */ if (p == &tree->root) return tree; q = p; /* T5: Next. */ tp = tp->link[1]; } } /* Unthreads the threaded tree TREE in-place, and returns TREE cast to avl_tree *. */ struct avl_tree * avltr_unthread (avltr_tree *tree) { /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13 (postorder traversal). */ /* T1. */ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */ int ap = 0; /* Stack A: height. */ avltr_node *p; assert (tree != NULL); p = tree->root.link[0]; if (p != NULL) for (;;) { /* T2. */ for (;;) { /* T3. */ ab[ap] = 0; an[ap++] = p; if (p->link[0] == NULL) break; p = p->link[0]; } /* T4. */ for (;;) { if (ap == 0) goto done; p = an[--ap]; if (ab[ap] == 0) { ab[ap++] = RIGHT; if (p->rtag == MINUS) continue; p = p->link[1]; break; } if (p->rtag == MINUS) p->link[1] = NULL; } } else tree->root.link[0] = NULL; done: tree->root.link[1] = NULL; return (struct avl_tree *) tree; } /* Walk tree TREE in inorder, calling WALK_FUNC at each node. Passes PARAM to WALK_FUNC. */ void avltr_walk (avltr_tree *tree, avl_node_func walk_func, int *param) { avltr_node *p = &tree->root; /* Uses Knuth's algorithm 2.3.1D (threaded inorder successor). */ assert (tree && walk_func); for (;;) { if (p->rtag == MINUS) p = p->link[1]; else { p = p->link[1]; while (p->link[0] != NULL) p = p->link[0]; } if (p == &tree->root) return; walk_func (p->data, param); } } /* Each call to this function for a given TREE and TRAV return the next item in the tree in inorder. Initialize the first element of TRAV (init) to 0 before calling the first time. Returns NULL when out of elements. */ cell_type * avltr_traverse (avltr_tree *tree, avltr_traverser *trav) { avltr_node *p; assert (tree && trav); if (trav->init == 0) { p = &tree->root; trav->init = RIGHT; } else p = trav->p; /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */ if (p->rtag == MINUS) p = p->link[1]; else { p = p->link[1]; while (p->link[0] != NULL) p = p->link[0]; } if (p == &tree->root) { trav->init = 0; return NULL; } else { trav->p = p; return p->data; } } /* Given ITEM, a pointer to a data item in TREE (or NULL), returns a pointer to the next item in the tree in comparison order, or NULL if ITEM is the last item. */ cell_type ** avltr_next ( avltr_tree *tree, cell_type **item) { avltr_node *p; assert (tree != NULL); if (item == NULL) p = &tree->root; else p = (avltr_node *) (((char *) item) - offsetof (avltr_node, data)); /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */ if (p->rtag == MINUS) p = p->link[1]; else { p = p->link[1]; while (p->link[0] != NULL) p = p->link[0]; } if (p == &tree->root) return NULL; return &p->data; } /* Search TREE for an item matching ITEM. If found, returns a pointer to the address of the item. If none is found, ITEM is inserted into the tree, and a pointer to the address of ITEM is returned. In either case, the pointer returned can be changed by the caller, or the returned data item can be directly edited, but the key data in the item must not be changed. */ cell_type **avltr_probe (avltr_tree *tree, cell_type *item) { /* Uses Knuth's Algorithm 6.2.3A (balanced tree search and insertion), modified for a right-threaded binary tree. Caches results of comparisons. In empirical tests this eliminates about 25% of the comparisons seen under random insertions. */ /* A1. */ avltr_node *t; avltr_node *s, *p, *q, *r; assert (tree != NULL); t = &tree->root; s = p = t->link[0]; if (s == NULL) { tree->count++; assert (tree->count == 1); q = t->link[0] = (avltr_node *) xmalloc (sizeof (avltr_node)); q->data = item; q->link[0] = NULL; q->link[1] = t; q->rtag = MINUS; q->bal = 0; return &q->data; } for (;;) { /* A2. */ int diff = tree->cmp (item, p->data, tree->param); /* A3. */ if (diff < 0) { p->cache = 0; q = p->link[0]; if (q == NULL) { /* Algorithm 2.3.1 exercise 23 for insertion to the left in a right-threaded binary tree. */ q = (avltr_node *) xmalloc (sizeof (avltr_node)); p->link[0] = q; q->link[0] = NULL; q->link[1] = p; q->rtag = MINUS; break; } } /* A4. */ else if (diff > 0) { p->cache = 1; q = p->link[1]; if (p->rtag == MINUS) { /* Algorithm 2.3.1 exercise 23 for insertion to the right in a right-threaded binary tree. */ q = (avltr_node *) xmalloc (sizeof (avltr_node)); q->link[1] = p->link[1]; q->rtag = p->rtag; p->link[1] = q; p->rtag = PLUS; q->link[0] = NULL; break; } assert (q != NULL); } else /* A2. */ return &p->data; /* A3, A4. */ if (q->bal != 0) t = p, s = q; p = q; } /* A5. */ tree->count++; q->data = item; q->bal = 0; /* A6. */ r = p = s->link[(int) s->cache]; while (p != q) { p->bal = p->cache * 2 - 1; p = p->link[(int) p->cache]; } /* A7. */ if (s->cache == 0) { /* a = LEFT. */ if (s->bal == 0) { s->bal = LEFT; return &q->data; } else if (s->bal == RIGHT) { s->bal = 0; return &q->data; } assert (s->bal == LEFT); if (r->bal == LEFT) { /* A8. */ p = r; if (r->rtag == MINUS) { s->link[0] = NULL; r->link[1] = s; r->rtag = PLUS; } else { s->link[0] = r->link[1]; r->link[1] = s; } s->bal = r->bal = 0; } else { /* A9. */ assert (r->bal == RIGHT); p = r->link[1]; r->link[1] = p->link[0]; p->link[0] = r; s->link[0] = p->link[1]; p->link[1] = s; if (p->bal == LEFT) s->bal = RIGHT, r->bal = 0; else if (p->bal == 0) s->bal = r->bal = 0; else { assert (p->bal == RIGHT); s->bal = 0, r->bal = LEFT; } p->bal = 0; p->rtag = PLUS; if (s->link[0] == s) s->link[0] = NULL; if (r->link[1] == NULL) { r->link[1] = p; r->rtag = MINUS; } } } else { /* a == RIGHT. */ if (s->bal == 0) { s->bal = RIGHT; return &q->data; } else if (s->bal == LEFT) { s->bal = 0; return &q->data; } assert (s->bal == RIGHT); if (r->bal == RIGHT) { /* A8. */ p = r; if (r->link[0] == NULL) { s->rtag = MINUS; r->link[0] = s; } else { s->link[1] = r->link[0]; s->rtag = PLUS; r->link[0] = s; } s->bal = r->bal = 0; } else { /* A9. */ assert (r->bal == LEFT); p = r->link[0]; r->link[0] = p->link[1]; p->link[1] = r; s->link[1] = p->link[0]; p->link[0] = s; if (p->bal == RIGHT) s->bal = LEFT, r->bal = 0; else if (p->bal == 0) s->bal = r->bal = 0; else { assert (p->bal == LEFT); s->bal = 0, r->bal = 1; } p->rtag = PLUS; if (s->link[1] == NULL) { s->link[1] = p; s->rtag = MINUS; } if (r->link[0] == r) r->link[0] = NULL; p->bal = 0; } } /* A10. */ if (t != &tree->root && s == t->link[1]) t->link[1] = p; else t->link[0] = p; return &q->data; } /* Search TREE for an item matching ITEM, and return a pointer to it if found. */ cell_type **avltr_find (avltr_tree *tree, cell_type *item) { avltr_node *p; assert (tree != NULL); p = tree->root.link[0]; if (p == NULL) return NULL; for (;;) { int diff = tree->cmp (item, p->data, tree->param); /* A3. */ if (diff < 0) { p = p->link[0]; if (p == NULL) return NULL; } else if (diff > 0) { if (p->rtag == MINUS) return NULL; p = p->link[1]; } else return &p->data; } } /* Search TREE for an item close to the value of ITEM, and return it. This function will return a null pointer only if TREE is empty. */ cell_type **avltr_find_close (avltr_tree *tree, cell_type *item) { avltr_node *p; assert (tree != NULL); p = tree->root.link[0]; if (p == NULL) return NULL; for (;;) { int diff = tree->cmp (item, p->data, tree->param); /* A3. */ if (diff < 0) { if (p->link[0]) p = p->link[0]; else return &p->data; } else if (diff > 0) { if (p->rtag == MINUS) return &p->data; p = p->link[1]; } else return &p->data; } } /* Searches AVL tree TREE for an item matching ITEM. If found, the item is removed from the tree and the actual item found is returned to the caller. If no item matching ITEM exists in the tree, returns NULL. */ cell_type *avltr_delete (avltr_tree *tree, cell_type *item) { /* Uses my Algorithm DTR, which can be found at http://www.msu.edu/user/pfaffben/avl. Algorithm DT is based on Knuth's Algorithms 6.2.2D (Tree deletion), 6.2.3A (Balanced tree search and insertion), 2.3.1I (Insertion into a threaded binary trees), and the notes on pages 465-466 of Vol. 3. */ /* D1. */ avltr_node *pa[AVL_MAX_HEIGHT]; /* Stack P: Nodes. */ unsigned char a[AVL_MAX_HEIGHT]; /* Stack P: Bits. */ int k = 1; /* Stack P: Pointer. */ avltr_node *p; assert (tree != NULL); a[0] = 0; pa[0] = &tree->root; p = tree->root.link[0]; if (p == NULL) return NULL; for (;;) { /* D2. */ int diff = tree->cmp (item, p->data, tree->param); if (diff == 0) break; /* D3, D4. */ pa[k] = p; if (diff < 0) { if (p->link[0] != NULL) { p = p->link[0]; a[k] = 0; } else return NULL; } else if (diff > 0) { if (p->rtag == PLUS) { p = p->link[1]; a[k] = 1; } else return NULL; } k++; } tree->count--; item = p->data; { avltr_node *t = p; avltr_node **q = &pa[k - 1]->link[(int) a[k - 1]]; /* D5. */ if (t->rtag == MINUS) { if (t->link[0] != NULL) { avltr_node *x = t->link[0]; *q = x; (*q)->bal = 0; if (x->rtag == MINUS) { if (a[k - 1] == 1) x->link[1] = t->link[1]; else x->link[1] = pa[k - 1]; } } else { *q = t->link[a[k - 1]]; if (a[k - 1] == 0) pa[k - 1]->link[0] = NULL; else pa[k - 1]->rtag = MINUS; } } else { /* D6. */ avltr_node *r = t->link[1]; if (r->link[0] == NULL) { r->link[0] = t->link[0]; r->bal = t->bal; if (r->link[0] != NULL) { avltr_node *s = r->link[0]; while (s->rtag == PLUS) s = s->link[1]; assert (s->rtag == MINUS); s->link[1] = r; } *q = r; a[k] = 1; pa[k++] = r; } else { /* D7. */ avltr_node *s = r->link[0]; a[k] = 1; pa[k++] = t; a[k] = 0; pa[k++] = r; /* D8. */ while (s->link[0] != NULL) { r = s; s = r->link[0]; a[k] = 0; pa[k++] = r; } /* D9. */ t->data = s->data; if (s->rtag == PLUS) r->link[0] = s->link[1]; else r->link[0] = NULL; p = s; } } } FREE(p); assert (k > 0); /* D10. */ while (--k) { avltr_node * s = pa[k]; if (a[k] == 0) { avltr_node * r = s->link[1]; /* D10. */ if (s->bal == LEFT) { s->bal = 0; continue; } else if (s->bal == 0) { s->bal = RIGHT; break; } assert (s->bal == RIGHT); if (s->rtag == MINUS || r->bal == 0) { /* D11. */ s->link[1] = r->link[0]; r->link[0] = s; r->bal = LEFT; pa[k - 1]->link[(int) a[k - 1]] = r; break; } else if (r->bal == RIGHT) { /* D12. */ if (r->link[0] != NULL) { s->rtag = PLUS; s->link[1] = r->link[0]; } else s->rtag = MINUS; r->link[0] = s; s->bal = r->bal = 0; pa[k - 1]->link[a[k - 1]] = r; } else { /* D13. */ assert (r->bal == LEFT); p = r->link[0]; if (p->rtag == PLUS) r->link[0] = p->link[1]; else r->link[0] = NULL; p->link[1] = r; p->rtag = PLUS; if (p->link[0] == NULL) { s->link[1] = p; s->rtag = MINUS; } else { s->link[1] = p->link[0]; s->rtag = PLUS; } p->link[0] = s; if (p->bal == RIGHT) s->bal = LEFT, r->bal = 0; else if (p->bal == 0) s->bal = r->bal = 0; else { assert (p->bal == LEFT); s->bal = 0, r->bal = RIGHT; } p->bal = 0; pa[k - 1]->link[(int) a[k - 1]] = p; if (a[k - 1] == 1) pa[k - 1]->rtag = PLUS; } } else { avltr_node * r = s->link[0]; /* D10. */ if (s->bal == RIGHT) { s->bal = 0; continue; } else if (s->bal == 0) { s->bal = LEFT; break; } assert (s->bal == LEFT); if (s->link[0] == NULL || r->bal == 0) { /* D11. */ s->link[0] = r->link[1]; r->link[1] = s; r->bal = RIGHT; pa[k - 1]->link[(int) a[k - 1]] = r; break; } else if (r->bal == LEFT) { /* D12. */ if (r->rtag == PLUS) s->link[0] = r->link[1]; else s->link[0] = NULL; r->link[1] = s; r->rtag = PLUS; s->bal = r->bal = 0; pa[k - 1]->link[a[k - 1]] = r; } else { /* D13. */ assert (r->bal == RIGHT); p = r->link[1]; if (p->link[0] != NULL) { r->rtag = PLUS; r->link[1] = p->link[0]; } else r->rtag = MINUS; p->link[0] = r; if (p->rtag == MINUS) s->link[0] = NULL; else s->link[0] = p->link[1]; p->link[1] = s; p->rtag = PLUS; if (p->bal == LEFT) s->bal = RIGHT, r->bal = 0; else if (p->bal == 0) s->bal = r->bal = 0; else { assert (p->bal == RIGHT); s->bal = 0, r->bal = LEFT; } p->bal = 0; if (a[k - 1] == 1) pa[k - 1]->rtag = PLUS; pa[k - 1]->link[(int) a[k - 1]] = p; } } } return item; } /* Inserts ITEM into TREE. Returns NULL if the item was inserted, otherwise a pointer to the duplicate item. */ cell_type *avltr_insert (avltr_tree *tree, cell_type *item) { cell_type **p; assert (tree != NULL); p = avltr_probe (tree, item); return (*p == item) ? NULL : *p; } /* If ITEM does not exist in TREE, inserts it and returns NULL. If a matching item does exist, it is replaced by ITEM and the item replaced is returned. The caller is responsible for freeing the item returned. */ cell_type *avltr_replace (avltr_tree *tree, cell_type *item){ cell_type **p; assert (tree != NULL); p = avltr_probe (tree, item); if (*p == item) return NULL; else { cell_type *r = *p; *p = item; return r; } } /* Delete ITEM from TREE when you know that ITEM must be in TREE. For debugging purposes. */ cell_type *(avltr_force_delete) (avltr_tree *tree, cell_type *item) { cell_type *found = avltr_delete (tree, item); assert (found != NULL); return found; } #if SELF_TEST /* Size of the tree used for testing. */ #define TREE_SIZE 1024 /* Used to flag delayed aborting. */ bool done = false; /* Count the number of nodes in TREE below and including NODE. */ int count (avltr_tree *tree, avltr_node *node) { int n = 1; if (node->link[0] != NULL) n += count (tree, node->link[0]); if (node->rtag == PLUS) n += count (tree, node->link[1]); return n; } /* Print the structure of node NODE of an avl tree, which is LEVEL levels from the top of the tree. Uses different delimiters to visually distinguish levels. */ void print_structure (avltr_tree *tree, avltr_node *node, int level) { char lc[] = "([{<`"; char rc[] = ")]}>'"; if (node == NULL) { Rprint (" :nil"); return; } else if (level >= 10) { Rprint ("Too deep, giving up.\n"); done = true; return; } else if (node == &tree->root) { Rprint (" root"); return; } Rprint (" %c%d", lc[level % 5], (int) node->data); fflush (stdout); print_structure (tree, node->link[0], level + 1); fflush (stdout); if (node->rtag == PLUS) print_structure (tree, node->link[1], level + 1); else if (node->link[1] != &tree->root) Rprint (" :%d", (int) node->link[1]->data); else Rprint (" :r"); fflush (stdout); Rprint ("%c", rc[level % 5]); fflush (stdout); } /* Compare two integers A and B and return a STRCMP()-type result. */ int compare_ints (int *a, int *b, int *param unused) { return ( a - b); } /* Print the value of integer A. */ void print_int (int *a, int *param unused) { Rprint (" %d", (int) a); } /* Linearly print contents of TREE. */ // void print_contents (avltr_tree *tree) { avltr_walk (tree, print_int, NULL); Rprint ("\n"); } /* Examine NODE in a avl tree. *COUNT is increased by the number of nodes in the tree, including the current one. If the node is the root of the tree, PARENT should be INT_MIN, otherwise it should be the parent node value. DIR is the direction that the current node is linked from the parent: LEFT for left child, RIGHT for right child; it is not used if PARENT is INT_MIN. Returns the height of the tree rooted at NODE. */ int recurse_tree (avltr_tree *tree, avltr_node *node, int *count, int parent, int dir, unsigned char *nodes, unsigned char *threads) { if (node != NULL && node != &tree->root) { int d = (int) node->data; int nl = 0; int nr = 0; (*count)++; assert (d >= 0 && d < TREE_SIZE); if (nodes[d / 8] & (1 << (d % 8))) { Rprint (" Arrived at node %d by two different paths.\n", d); done = true; } else nodes[d / 8] |= 1 << (d % 8); if (node->link[0] != NULL) nl = recurse_tree (tree, node->link[0], count, d, LEFT, nodes, threads); if (node->rtag == PLUS) { if (node->link[1] == NULL) { Rprint (" Null thread link.\n"); done = true; } nr = recurse_tree (tree, node->link[1], count, d, 1, nodes, threads); } else if (node->link[1] != &tree->root) { int dr = (int) node->link[1]->data; assert (dr >= 0 && dr < TREE_SIZE); if (threads[dr / 8] & (1 << dr % 8)) { Rprint (" Multiple threads to node %d.\n", d); done = true; } threads[dr / 8] |= 1 << (dr % 8); } if (nr - nl != node->bal) { Rprint (" Node %d has incorrect balance: right height=%d, " "left height=%d, difference=%d, but balance factor=%d.\n", d, nr, nl, nr - nl, node->bal); done = true; } if (node->bal < LEFT || node->bal > 1) { Rprint (" Node %d has invalid balance factor %d.\n", d, node->bal); done = true; } if (parent != INT_MIN) { assert (dir == LEFT || dir == RIGHT); if (dir == LEFT && d > parent) { Rprint (" Node %d is smaller than its left child %d.\n", parent, d); done = true; } else if (dir == RIGHT && d < parent) { Rprint (" Node %d is larger than its right child %d.\n", parent, d); done = true; } } assert (node->bal >= LEFT && node->bal <= 1); return 1 + (nl > nr ? nl : nr); } else return 0; } /* Check that everything about TREE is kosher. */ void verify_tree (avltr_tree *tree) { { unsigned char nodes[(TREE_SIZE + 7) / 8]; unsigned char threads[(TREE_SIZE + 7) / 8]; int count = 0; int i; memset (nodes, 0, (TREE_SIZE + 7) / 8); memset (threads, 0, (TREE_SIZE + 7) / 8); recurse_tree (tree, tree->root.link[0], &count, INT_MIN, 0, nodes, threads); if (count != tree->count) { Rprint (" Tree should have %d nodes, but tree count by recursive " "descent is %d.\n", tree->count, count); done = true; } for (i = 0; i < TREE_SIZE; i++) { int thread = threads[i / 8] & (1 << (i % 8)); int node = nodes[i / 8] & (1 << (i % 8)); if (thread && !node) { Rprint (" A thread leads to 'node' %d, " "which is not in the tree.", i); done = true; } } } /* Check threads. */ { int count = 0; int last = INT_MIN; cell_type **data = NULL; while (NULL != (data = avltr_next (tree, data))) { if (((int) *data) < last) { Rprint (" Misordered right threads.\n"); abort (); } else if (((int) *data) == last) { Rprint (" Loop in right threads detected on %d.\n", last); abort (); } last = (int) *data; count++; } if (count != tree->count) { Rprint (" Tree should have %d nodes, but tree count by right threads " "is %d.\n", tree->count, count); done = true; } } if (done) abort (); } /* Arrange the N elements of ARRAY in random order. */ void shuffle (int *array, int n) { int i; for (i = 0; i < n; i++) { int j = i + rand () % (n - i); int t = array[j]; array[j] = array[i]; array[i] = t; } } /* Compares avl trees rooted at A and B, making sure that they are identical. */ void compare_trees (avltr_node *a, avltr_node *b) { int diff = 0; assert (a && b); /* Separating these conditions makes it easier to pinpoint bad data under a memory debugger like Checker because each test is a separate statement. */ diff |= a->data != b->data; diff |= a->bal != b->bal; diff |= ((a->link[0] != NULL) ^ (b->link[0] != NULL)); diff |= ((a->rtag == PLUS) ^ (b->rtag == PLUS)); if (diff) { Rprint (" Copied nodes differ: %d b=%d a->bal=%d b->bal=%d a:", (int) a->data, (int) b->data, a->bal, b->bal); if (a->link[0]) Rprint ("l"); if (a->link[1]) Rprint ("r"); Rprint (" b:"); if (b->link[0]) Rprint ("l"); if (b->link[1]) Rprint ("r"); Rprint ("\n"); abort (); } if (a->link[0] != NULL) compare_trees (a->link[0], b->link[0]); if (a->rtag == PLUS) compare_trees (a->link[1], b->link[1]); } /* Simple stress test procedure for the AVL tree routines. Does the following: * Generate a random number seed. By default this is generated from the current time. You can also pass a seed value on the command line if you want to test the same case. The seed value is displayed. * Create a tree and insert the integers from 0 up to TREE_SIZE - 1 into it, in random order. Verify the tree structure after each insertion. * Remove each integer from the tree, in a different random order. After each deletion, verify the tree structure; also, make a copy of the tree into a new tree, verify the copy and compare it to the original, then destroy the copy. * Destroy the tree, increment the random seed value, and start over. If you make any modifications to the avl tree routines, then you might want to insert some calls to print_structure() at strategic places in order to be able to see what's really going on. Also, memory debuggers like Checker or Purify are very handy. */ #define N_ITERATIONS 16 int main (int argc, char **argv) { int array[TREE_SIZE]; int seed; int iteration; if (argc == 2) seed = atoi (argv[1]); else seed = time (0) * 257 % 32768; Rprint("Testing avltr...\n", stdout); for (iteration = 1; iteration <= N_ITERATIONS; iteration++) { avltr_tree *tree; int i; Rprint ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed); fflush (stdout); srand (seed++); for (i = 0; i < TREE_SIZE; i++) array[i] = i; shuffle (array, TREE_SIZE); tree = avltr_create (compare_ints, NULL); for (i = 0; i < TREE_SIZE; i++) avltr_force_insert (tree, array[i]); verify_tree (tree); shuffle (array, TREE_SIZE); for (i = 0; i < TREE_SIZE; i++) { avltr_tree *copy; avltr_delete (tree, array[i]); verify_tree (tree); copy = avltr_copy (tree, NULL); verify_tree (copy); if (tree->root.link[0] != NULL) compare_trees (tree->root.link[0], copy->root.link[0]); else if (copy->root.link[0] != NULL) { Rprint (" Empty tree results in nonempty copy.\n"); abort (); } avltr_destroy (copy, NULL); if (i % 128 == 0) { Rprint("."); fflush (stdout); } } Rprint(" good.\n", stdout); avltr_destroy (tree, NULL); } return 0; } #endif /* SELF_TEST */ /* Local variables: compile-command: "gcc -DSELF_TEST=1 -W -Wall -I. -o ./avltr-test avltr.c" End: */ RandomFields/src/primitive.others.cc0000644000176200001440000004701213437301605017240 0ustar liggesusers /* Authors Martin Schlather, schlather@math.uni-mannheim.de Definition of other simple function Copyright (C) 2017 -- 2018 Martin Schlather This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "questions.h" #include "RF.h" #include "primitive.others.h" #include "Coordinate_systems.h" #include "operator.h" #include "QMath.h" //#include "AutoRandomFields.h" //#include "shape.h" //#include "Processes.h" // Sigma(x) = diag>0 + A'xx'A void kappa_Angle(int i, model *cov, int *nr, int *nc){ int dim = OWNXDIM(0); *nr = i == ANGLE_DIAG ? dim : 1; *nc = i <= ANGLE_DIAG && (dim==3 || i != ANGLE_LATANGLE) && (dim==2 || i != ANGLE_RATIO) ? 1 : -1; } void AngleMatrix(model *cov, double *A) { double c, s, *diag = P(ANGLE_DIAG); if (GLOBAL.coords.anglemode == radians) { c = COS(P0(ANGLE_ANGLE)); s = SIN(P0(ANGLE_ANGLE)); } else { assert(GLOBAL.coords.anglemode == degree); c = COS(P0(ANGLE_ANGLE) * piD180); s = SIN(P0(ANGLE_ANGLE) * piD180); } int dim = OWNXDIM(0) ; assert(dim ==2 || dim == 3); if (dim == 2) { A[0] = c; A[1] = s; A[2] = -s; A[3] = c; } else { double pc, ps; if (GLOBAL.coords.anglemode == radians) { pc = COS(P0(ANGLE_LATANGLE)); ps = SIN(P0(ANGLE_LATANGLE)); } else { pc = COS(P0(ANGLE_LATANGLE) * piD180); ps = SIN(P0(ANGLE_LATANGLE) * piD180); } /* c -s 0 pc 0 -ps c*pc -s -c*ps s c 0 * 0 1 0 = s*pc c -s*ps 0 0 1 ps 0 pc ps 0 pc */ A[0] = c * pc; A[1] = s * pc; A[2] = ps; A[3] = -s; A[4] = c; A[5] = 0.0; A[6] = -c * ps; A[7] = -s * ps; A[8] = pc; } if (diag!= NULL) { int k,d,j; for (k=d=0; dmpp.maxheights[0] = RF_NA; cov->matrix_indep_of_x = true; RETURN_NOERROR; } void rangeAngle(model *cov, range_type* range){ model *calling = cov->calling; assert(calling != NULL); range->min[ANGLE_ANGLE] = 0.0; range->max[ANGLE_ANGLE] = calling->vdim[0] == SCALAR && isDollar(calling) && calling->sub[0] != cov && // so a parameter of dollar SYSTEMS(CALLING) == 1 && isSymmetric(ISO(CALLING, 0)) ? PI : TWOPI; range->pmin[ANGLE_ANGLE] = 0.0; range->pmax[ANGLE_ANGLE] = range->max[ANGLE_ANGLE]; range->openmin[ANGLE_ANGLE] = false; range->openmax[ANGLE_ANGLE] = true; range->min[ANGLE_LATANGLE] = 0.0; range->max[ANGLE_LATANGLE] = PI; range->pmin[ANGLE_LATANGLE] = 0.0; range->pmax[ANGLE_LATANGLE] = PI; range->openmin[ANGLE_LATANGLE] = false; range->openmax[ANGLE_LATANGLE] = true; range->min[ANGLE_RATIO] = 0; range->max[ANGLE_RATIO] = RF_INF; range->pmin[ANGLE_RATIO] = 1e-5; range->pmax[ANGLE_RATIO] = 1e5; range->openmin[ANGLE_RATIO] = false; range->openmax[ANGLE_RATIO] = true; range->min[ANGLE_DIAG] = 0; range->max[ANGLE_DIAG] = RF_INF; range->pmin[ANGLE_DIAG] = 1e-5; range->pmax[ANGLE_DIAG] = 1e5; range->openmin[ANGLE_DIAG] = false; range->openmax[ANGLE_DIAG] = true; } void idcoord(double *x, model *cov, double *v){ int d, vdim = VDIM0; for (d=0; dmin[NULL_TYPE] = TcfType; range->max[NULL_TYPE] = OtherType; range->pmin[NULL_TYPE] = TcfType; range->pmax[NULL_TYPE] = OtherType; range->openmin[NULL_TYPE] = false; range->openmax[NULL_TYPE] = false; } int checkMath(model *cov){ int i, variables = DefList[COVNR].kappas, err = NOERROR; if (variables > 2) kdefault(cov, variables-1, 1.0); if (isEarth(OWNISO(0))) { defn *C = DefList + COVNR; if ((C->cov==MathCos || C->cov==MathSin || C->cov==MathTan)) { // printI(cov); // printf("%.50s\n", TYPE_NAMES[DEFTYPE(0)]); // APMI0(cov); SERR1("only radians as angular system allowed for '%.50s'.", NICK(cov)); } } for (i=0; ikappasub[i]; if (sub != NULL) { if (i >= 2) SERR("only numerics allowed"); bool plus = DefList[SUBNR].cov == Mathplus || DefList[SUBNR].check == checkplus || DefList[SUBNR].cov == Mathminus ; if ((err = CHECK_PASSTF(sub, plus ? OWNTYPE(0) : ShapeType, // auch falls cov = TrendType ist 1, cov->frame)) != NOERROR){ // if ((err = CHECK(sub, cov->tsdim, cov->xdimown, /// plus ? cov->typus : ShapeType, // // auch falls cov = TrendType ist // OWNDOM(0), OWNISO(0), // 1, cov->frame)) != NOERROR){ RETURN_ERR(err); } if (sub->vdim[0] != 1 || sub->vdim[1] != 1) SERR("only scalar functions are allowed"); setbackward(cov, sub); } else if (PisNULL(i)) { if (i==0 || (DefList[COVNR].cov!=Mathplus && DefList[COVNR].cov!=Mathminus && DefList[COVNR].cov!=Mathbind )) SERR("not enough arguments given") else break; } } cov->pref[Trendproc] = 5; cov->pref[Direct] = 1; RETURN_NOERROR; } void rangeMath(model VARIABLE_IS_NOT_USED *cov, range_type *range){ int i, variables = DefList[COVNR].kappas; set_maxdim(OWN, 0, OWNLOGDIM(0)); assert(MAXDIM(OWN, 0) > 0); for (i=0; imin[i] = RF_NEGINF; range->max[i] = RF_INF; range->pmin[i] = -1e5; range->pmax[i] = 1e5; range->openmin[i] = true; range->openmax[i] = true; } } void Mathminus(double *x, model *cov, double *v){ MATH_DEFAULT; double f = P0(MATH_FACTOR); if (ISNAN(f)) f = 1.0; *v = ( (PisNULL(1) && cov->kappasub[1]==NULL) ? -w[0] : w[0]- w[1]) * f; } void Mathplus(double *x, model *cov, double *v){ MATH_DEFAULT; double f = P0(MATH_FACTOR); if (ISNAN(f)) f = 1.0; *v = ( (PisNULL(1) && cov->kappasub[1]==NULL)? w[0] : w[0] + w[1]) * f; } void Mathdiv(double *x, model *cov, double *v){ MATH_DEFAULT; double f = P0(MATH_FACTOR); if (ISNAN(f)) f = 1.0; *v = (w[0] / w[1]) * f; } void Mathmult(double *x, model *cov, double *v){ MATH_DEFAULT; double f = P0(MATH_FACTOR); if (ISNAN(f)) f = 1.0; *v = (w[0] * w[1]) * f; } #define IS_IS 1 void Mathis(double *x, model *cov, double *v){ int i, variables = DefList[COVNR].kappas; double w[3]; for (i=0; ikappasub[i]; if (sub != NULL) { COV(x, sub, w + i); } else { w[i] = i == IS_IS ? P0INT(i) : P0(i); } } switch((int) w[IS_IS]) { case 0 : *v = (double) (FABS(w[0] - w[2]) <= GLOBAL.nugget.tol); break; case 1 : *v = (double) (FABS(w[0] - w[2]) > GLOBAL.nugget.tol); break; case 2 : *v = (double) (w[2] + GLOBAL.nugget.tol >= w[0]); break; case 3 : *v = (double) (w[2] + GLOBAL.nugget.tol > w[0]); break; case 4 : *v = (double) (w[0] + GLOBAL.nugget.tol >= w[2]); break; case 5 : *v = (double) (w[0] + GLOBAL.nugget.tol > w[2]); break; default : BUG; } } void rangeMathIs(model *cov, range_type *range){ rangeMath(cov, range); range->min[IS_IS] = 0; range->max[IS_IS] = 5; range->pmin[IS_IS] = 0; range->pmax[IS_IS] = 5; range->openmin[IS_IS] = false; range->openmax[IS_IS] = false; } void Mathbind(double *x, model *cov, double *v){ int vdim = VDIM0; MATH_DEFAULT_0(vdim); double f = P0(DefList[COVNR].kappas - 1); f = ISNAN(f) ? 1.0 : f; for (i=0; i 0 && cov->nrow[variables - 1] == 0 && cov->kappasub[variables - 1] == NULL) variables--; VDIM0 = variables / ncol; VDIM1 = ncol; if (VDIM0 * VDIM1 != variables) SERR1("'%.50s' does not fit the number of components given", KNAME(BIND_NCOL)); cov->ptwise_definite = pt_mismatch; RETURN_NOERROR; } bool allowedDbind(model *cov) { defn *C = DefList + COVNR; int i, kappas = C->kappas; for (i=0; ikappasub[i] != NULL) break; if (iallowedD; for (int j=(int) FIRST_DOMAIN; j<=(int) LAST_DOMAINUSER; D[j++] = false); for (; ikappasub[i]; if (k != NULL) { allowed &= allowedD(k); for (int j=(int) FIRST_DOMAIN; j<=(int) LAST_DOMAINUSER; j++) D[j] |= k->allowedD[j]; } } //printD(cov);printf("allowd.c=%d\n", allowed); return allowed; } //printf("Allowd.c=%d\n", allowedItrue(cov)); return allowedItrue(cov); } bool allowedIbind(model *cov) { defn *C = DefList + COVNR; int i, kappas = C->kappas; for (i=0; ikappasub[i] != NULL) break; if (iallowedI; for (int j=(int) FIRST_ISOUSER; j<=(int) LAST_ISOUSER; I[j++] = false); for (; ikappasub[i]; if (k != NULL) { allowed |= allowedI(k); for (int j=(int) FIRST_ISOUSER; j<=(int) LAST_ISOUSER; j++) I[j] &= k->allowedI[j]; } } // printI(cov);printf("allowdI.c=%d\n", allowed); return allowed; } return allowedItrue(cov); } Types Typebind(Types required, model VARIABLE_IS_NOT_USED *cov, isotropy_type VARIABLE_IS_NOT_USED iso) { return required; /* defn *C = DefList + COVNR; int i, kappas = C->kappas; for (i=0; ikappasub[i] != NULL) break; if (icalling == NULL) BUG; model *pp = cov->calling->calling; // the following defines a (positive) constant on the level of a trend // to be a trend, and not a positive definite function // For spatially constant covariance functions, see RMconstant if (pp == NULL || (CALLINGNR == PLUS && !isnowNegDef(pp) && !isnowTrend(pp))){ RETURN_ERR(ERRORFAILED); // by definition, } } if (cov->kappasub[0] != NULL) SERR("only numerics allowed"); cov->ptwise_definite = P0(CONST_C) > 0 ? pt_posdef : P0(CONST_C) < 0 ? pt_negdef : pt_zero; if (tcf) MEMCOPY(cov->pref, PREF_ALL, sizeof(pref_shorttype)); GLOBAL.internal.warn_mathdef = GLOBAL.internal.warn_mathdef == False ? False : isNegDef(PREVTYPE(0)) ? True : Nan; RETURN_NOERROR; } void rangec(model *cov, range_type *range){ rangeconstant(cov, range); } bool allowedIp(model *cov) { bool *I = cov->allowedI; for (int i=(int) FIRST_ISOUSER; i<=(int) LAST_ISOUSER; I[i++] = false); if (!PisNULL(PROJ_ISO)) { isotropy_type iso = (isotropy_type) P0INT(PROJ_ISO); I[iso] = true; switch(iso) { case ISOTROPIC: case EARTH_ISOTROPIC: case SPHERICAL_ISOTROPIC : I[iso] = true; break; case DOUBLEISOTROPIC : case VECTORISOTROPIC : ERR("'VECTORISOTROPY' not programmed yet"); case SYMMETRIC : case EARTH_SYMMETRIC: case SPHERICAL_SYMMETRIC : ERR2("Use '%.50s' within arbitrarty mathematical definitions (i.e. in '%.50s') or use the argument 'proj' within definite functions)", CoordinateSystemOf(iso), NICK(cov)); break; case CARTESIAN_COORD: case SPHERICAL_COORD: case EARTH_COORD: I[iso] = true; break; case GNOMONIC_PROJ : case ORTHOGRAPHIC_PROJ : ERR("Do not use projection in 'R,p', but use 'RMtrafo' instead."); break; case UNREDUCED : I[CARTESIAN_COORD] = I[SPHERICAL_COORD] = I[EARTH_COORD] = true; break; default : ERR2("'%.50s' not allowed for '%.50s'", ISO_NAMES[iso],KNAME(PROJ_ISO)); } } else { I[CARTESIAN_COORD] = I[SPHERICAL_COORD] = I[EARTH_COORD] = true; } return false; } void proj(double *x, model *cov, double *v){ double f = P0(PROJ_FACTOR); if (ISNAN(f)) f = 1.0; int p = P0INT(PROJ_PROJ); if (p >= 1) { *v = x[p - 1] * f; // PMIR(cov); BUG; // printf("nr=%d f=%10g p=%d x=%10g v=%10g\n", cov->zaehler, f, p, x[p-1], *v); return; } if (p == PROJ_TIME) *v = x[OWNTOTALXDIM - 1] * f; else if (p == PROJ_SPACE) { double dummy = 0.0; int spdim = OWNTOTALXDIM - 1; for (int d = 0; dmin[PROJ_PROJ] = -PROJECTIONS; range->max[PROJ_PROJ] = OWNXDIM(0); range->pmin[PROJ_PROJ] = 1; range->pmax[PROJ_PROJ] = OWNXDIM(0); range->openmin[PROJ_PROJ] = false; range->openmax[PROJ_PROJ] = false; range->min[PROJ_ISO] = FIRST_ISOUSER; range->max[PROJ_ISO] = LAST_ISOUSER; range->pmin[PROJ_ISO] = FIRST_ISOUSER; range->pmax[PROJ_ISO] = LAST_ISOUSER; range->openmin[PROJ_ISO] = false; range->openmax[PROJ_ISO] = false; range->min[PROJ_FACTOR] = RF_NEGINF; range->max[PROJ_FACTOR] = RF_INF; range->pmin[PROJ_FACTOR] = - 1e5; range->pmax[PROJ_FACTOR] = 1e5; range->openmin[PROJ_FACTOR] = true; range->openmax[PROJ_FACTOR] = true; } void declarefct(double VARIABLE_IS_NOT_USED *x, model *cov, double *v){ int vdimSq = VDIM0 * VDIM1; for (int i=0; imin[i] = RF_NEGINF; range->max[i] = RF_INF; range->pmin[i] = RF_NEGINF; range->pmax[i] = RF_INF; range->openmin[i] = true; range->openmax[i] = true; } } int checkdeclare(model *cov) { // defn *C = DefList + COVNR; int v = cov->calling->vdim[0]; // kappas = C->kappas; // for (int i=0; i