coe_sum: Summerization of all available paramter fittings.

Description Usage Arguments Value See Also Examples

Description

nls_1d_fit fit the requested non-linear models, such as double weibull model.

coe_lm basically fit linear models to the fitted parameters produced by nls_1d_fit.

coe_sum wraps coe_lm and coe_gam together. It save the numerical results into files and save all the plots into a single pdf file if requested. All the arugments are directly copied from those two functions, which a few new ones explained as below. Note that read_3d is called inside.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
nls_1d_fit(mat, picked, func, 
    para.initials = list(a1 = 0.03, b1 = 1, a2 = 0.3, b2 = 0.6))
    
coe_lm(mat, weights, picked, func, xlabel,
    para.initials = list(a1 = 0.03, b1 = 1, a2 = 0.3, b2 = 0.6))

coe_sum(data.name, data, 
    data.folder="I:/Dropbox/1_STB Project/R scripts/Output 3D",
    weights, picked, selected, func, 
    para.initials = list(a1 = 0.03, b1 = 1, a2 = 0.3, b2 = 0.6), 
    dist = 3, trans = "log", output = TRUE, intg.length = 0, 
    func.name, xlab, ylab = "Integral", file.folder = getwd(), 
    file.name, auto.smooth = TRUE, pdf = TRUE)

Arguments

mat

The big data frame generated by the 3D macro in SAS, after changing all 0 values to NA.

data

You can also supplied the data.frame already loaded in R. data and data.name can not be both presented.

data.name

It's a character string, the name of the csv file (not includeing ".csv") you saved by SAS in directory data.folder.

data.folder

Where you put the CSV SAS output.

weights

The weights used in weighted linear regression. But it's not recommended to use weighted linear regression.

picked

The cases of different lengthes you want to fit the model. Suppose you want to fit double weibull models for all lengthes ranging from 20-1040 min, then picked=20:1040. If you want to fit some specific cases, such as only 300, 400, 500, 580, then picked=c(300, 400, 500, 580).

func

The function you used in nls fitting. If you want to fit double weibull model, then func=double.weibull.b.

xlabel

You have to be conscious of what kind of data you're dealing with. If the columns of mat are STBS length cases, then you can specify anything like xlabel="length"; if they are QHs, then you have to specify xlabel="qh". This argument is to get the xlabel in the output plots right.

para.initials

The initial values of the parameters in doing nls fitting. It should be a list with item numbers and names exactly matching the function you used here. Such as in double weibull fitting, we use function double.weibull.b, and in this case the default para.initials should be used.

selected

If you want to present the model fitting of some specific or questionable cases in the pdf plot, you should specify those cases here as selected=c(38, 241, 242).

dist

The criteria to judge if a fitted parameter is an outlier. dist=3 means 3 standard deviation from the mean would be considered as an outlier.

trans

The transformation requested before apply the gam smoothing.

output

If output files of the gam fitting results and the integration results are requested.

intg.length

The length of doing numerical integration. Default is 0, which means such integration will be done dynamically depending on STBS length. If STBS length is 300, then the integration will be done from 0-300 min. Otherwisely, all integration will be from 0 to the length you specified, regardless of the STBS length.

func.name

The name of the function you used in fitting the model. It should be a character string such as func.name="double.weibull.b".

xlab

The xlab for the gam and integration plot. If each fitting is done by STBS length, then the lable should be something like xlab="length"; if it's done by QH, then xlab="QH in day time".

ylab

The ylab for the integration plot.

file.folder

If output=T, you need to specify where should those files go

file.name

If output=T, you need to specify the name of the files to be saved.

auto.smooth

If you request auto gam smooth in the integration plot. Sometimes auto smooth doesn't make any sense.

pdf

If you want the pdf output or not.

Value

coe_sum return all the three major fitting result entirely during fitting, the coe_lm, coe_gam and the selected nls_1d_fit object. Thus it's a list of 3 futher list.

See Also

You can also check coe_gam.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(ggplot2); library(mgcv)

#data
feb_5k_3d[1:5, 1:20]

#nls_1d_fit
nls_1d_fit(mat=feb_5k_3d, picked=seq(30, 360, by=40), 
           func=double.weibull.b)

#coe_lm
coelm_FEB_5KS30_non_wkday <- coe_lm(mat=feb_5k_3d,picked=30:300,
                                    func=double.weibull.b, xlabel="Length")

#coe_gam
coe_gam(data=coelm_FEB_5KS30_non_wkday$nls_fitting_all,output=FALSE)

#coe_sum
coesum_FEB_5KS30_non_wkday <- 
  coe_sum(data=feb_5k_3d, picked=30:300, 
          selected=seq(30, 300, by=40),
          xlab="STBS Length", 
          func=double.weibull.b,
          func.name="double.weibull.b", intg.length=0, 
          file.name="coesum_FEB_5KS30_non_wkday")

fzwaeustc/pcrfn documentation built on May 16, 2019, 4:06 p.m.