fps_lm: Full pattern summation using linear regression

Description Usage Arguments Details Value Examples

View source: R/fps_lm.R

Description

fps_lm returns a simple fit of a given pattern using linear regression, where coefficients may be either positive or negative. Does not return quantitative data. For quantitative results use fps or afps.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
fps_lm(
  lib,
  smpl,
  harmonise,
  refs,
  std,
  tth_align,
  align,
  manual_align,
  tth_fps,
  shift,
  p,
  ...
)

Arguments

lib

A powdRlib object representing the reference library. Created using the powdRlib constructor function.

smpl

A data frame. First column is 2theta, second column is counts

harmonise

logical parameter defining whether to harmonise the lib and smpl. Default = TRUE. When TRUE the function harmonises the lib and smpl data to the intersecting 2theta range at the coarsest resolution available using natural splines.

refs

A character string of reference pattern IDs or names from the specified library. The IDs or names supplied must be present within the lib$phases$phase_id or lib$phases$phase_name columns. If missing from the function call then all phases in the reference library will be used.

std

The phase ID (e.g. "QUA.1") to be used as internal standard. Must match an ID provided in the refs parameter.

tth_align

A vector defining the minimum and maximum 2theta values to be used during alignment (e.g. c(5,65)). If not defined, then the full range is used.

align

The maximum shift that is allowed during initial 2theta alignment (degrees). Default = 0.1.

manual_align

A logical operator denoting whether to optimise the alignment within the negative/position 2theta range defined in the align argument, or to use the specified value of the align argument for alignment of the sample to the standards. Default = FALSE, i.e. alignment is optimised.

tth_fps

A vector defining the minimum and maximum 2theta values to be used during full pattern summation (e.g. c(5,65)). If not defined, then the full range is used.

shift

A single numeric value denoting the maximum (positive or negative) shift, in degrees 2theta, that is allowed during the shifting of selected phases. Default = 0.

p

a numeric parameter between 0 and 1 specifying the p-value limit for coefficients. Any reference patterns with a p-value greater than this value will be omitted from the linear regression and results recomputed. Must be greater than 0.000001 but no greater than 1.

...

Other arguments

Details

Requires a powdRlib library of reference patterns. Mineral concentrations are not quantified and therefore reference intensity ratios are not required.

Value

a powdRlm object with components:

tth

a vector of the 2theta scale of the fitted data

fitted

a vector of the fitted XRPD pattern

measured

a vector of the original XRPD measurement (aligned)

residuals

a vector of the residuals (fitted vs measured)

phases

a dataframe of the phases used to produce the fitted pattern

phases_grouped

the phases dataframe grouped by phase_name and summed

weighted_pure_patterns

a dataframe of reference patterns used to produce the fitted pattern. All patterns have been weighted according to the coefficients used in the fit

coefficients

a named vector of coefficients used to produce the fitted pattern

inputs

a list of input arguments used in the function call

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
25
data(rockjock)
data(rockjock_mixtures)

#Compute the PCA and loadings
x1 <- xrpd_pca(rockjock_mixtures,
               mean_center = TRUE,
               bin_size = 1,
               root_transform = 1)

## Not run: 
fps_lm_out <- fps_lm(rockjock,
                     smpl = data.frame("x" = x1$loadings$tth,
                                       "y" = x1$loadings$Dim.1),
                     refs = rockjock$phases$phase_id,
                     std = "QUARTZ",
                     align = 0.3,
                     p = 0.01)

plot(fps_lm_out,
     wavelength = "Cu",
     interactive = TRUE,
     group = TRUE)


## End(Not run)

powdR documentation built on Aug. 13, 2021, 5:08 p.m.