Mode {GCDkit} | R Documentation |
The functions 'Mode
' and 'ModeC
' calculate the best approximations of the
mode given major-
element compositions of the rock and its main
mineral constituents. Function 'WRComp
' does the
opposite, i.e. yields the whole-rock composition given
the chemistry of individual minerals and their modal proportions.
ModeMain(WR,sample.id="",select.oxides=TRUE,select.minerals=TRUE) Mode(rock, mins,sample.id="") ModeC(rock, mins,sample.id="") ModeAll(WR) WRComp(mins, f)
WR |
a numerical matrix; the whole-rock data to be normalized. |
rock |
whole-rock composition of the given sample. |
sample.id |
(optional) sample name. |
select.oxides |
(logical) should be selected oxides used for calculation? |
select.minerals |
(logical) should be selected minerals used for calculation? |
mins |
composition of its main rock-forming minerals. |
f |
their modal proportions. |
'Mode
' uses unconstrained least-squares method taking advantage of the
standard R function
'lsfit(mins,rock,intercept=F)
'. It produces results that generally
do not sum up to 100 % due to the presence of elements not used in
calculation (such as water), and, or, analytical noise.
'ModeC
' is the constrained variation whose output ought to sum up to 100 %
by definition (Albarede 1995). As such it seems to be more appropriate in
most applications.
In both cases, the printed output involves the input data, calculated modal
proportions of the individual minerals, the calculated composition of the rock
(using the auxiliary function 'WRComp
') and differences between the
approximated and the real data (residuals).
The sum of squared residuals is a measure of fit (as a rough guide it should be less than ca. 1).
The mineral compositions are provided by a tab-delimited ASCII file, whose first row contains the names of the determined oxides, the following ones start with the mineral abbreviation and the numeric data (hence the first row has one item less than the following ones).
'ModeMain
' is entry point to both
'Mode
' and 'ModeC
'
that enables the user to read the mineral data file,
select the oxides and minerals to be used in the calculation.
The options 'select.oxides=FALSE
' and
'select.minerals=FALSE
' read the mineral file in its entirety,
using all minerals and oxides present.
'ModeAll
' is a front end that performs the constrained least squares
calculation for samples specified by the function selectSamples
.
'ModeMain
', 'Mode
' and 'ModeC
' return a list with two
items. The first of them ('table
') is a matrix with the
real composition of the rock and its minerals, the calculated whole-rock
composition and the residuals. The second ('(un)constrained
') returns
calculated mineral proportions and sum of squared residuals.
'ModeAll
' returns a simple matrix listing, for each rock sample,
calculated proportions of rock-forming minerals and the sum of squared residuals.
'WRComp
' yields a vector with the calculated whole-rock composition.
Vojtěch Janoušek, vojtech.janousek@geology.cz
Albarede F (1995) Introduction to Geochemical Modeling. Cambridge University Press, Cambridge, p. 1-543
For example of the mineral data, see file 'Test_data\sazava mins.data
'.
# Albarede (1995) - page 7 # Calculate WRComposition of olivine gabbro containing 40 % olivine, # 30 % diopside and 30 % plagioclase. mins<-matrix(c(40.01,0.00,14.35,45.64,0.00,0.00,54.69,0.00,3.27,16.51, 25.52,0.00,48.07,33.37,0.00,0.00,16.31,2.25),3,6,byrow=TRUE) rownames(mins)<-c("ol","di","plg") colnames(mins)<-c("SiO2","Al2O3","FeO","MgO","CaO","Na2O") print(mins) # Direct task f<-c(0.4,0.3,0.3) names(f)<-c("ol","di","plg") print(f) rock<-WRComp(mins,f) print(rock) # Reverse unconstrained mode1<-Mode(rock,mins) # Reverse constrained mode2<-ModeC(rock,mins)