In my experiment, I diluted a chemical in water and recorded its Raman spectra. Then I repeated this with different concentrations. As I can clearly see some peaks decreasing in intensity when I dilute my solution, I hope that through Principal Component Regression, I would be able to automatically figure out which wavenumbers are useful for determining the concentration of my solution.
If I understand PCA correctly, I am looking for the loadings of the first few components.
I have the following data that I prepared:
> concentration.hcl
0.001 0.001 0.001 1e-04 1e-04 1e-04 1e-04 1e-09 1e-09 1e-09 1e-09 1e-11 1e-11
1e-03 1e-03 1e-03 1e-04 1e-04 1e-04 1e-04 1e-09 1e-09 1e-09 1e-09 1e-11 1e-11
1e-11 1e-11 1e-11
1e-11 1e-11 1e-11
and spectra.hcl with each row being a reading corresponding to an entry in concentration.hcl and the columns being a specific wavenumber.
> dim(spectra.hcl)
[1] 16 2048
> colnames(spectra.hcl)
[1] "-818.41" "-813.78" "-809.16" "-804.53" "-799.92" "-795.31" "-790.7"
[8] "-786.1" "-781.5" "-776.91" "-772.32" "-767.74" "-763.16" "-758.59"
[15] "-754.02" "-749.45" "-744.9" "-740.34" "-735.79" "-731.25" "-726.71" ...
I ran the following code:
pmodel <- pcr(concentration.hcl ~ spectra.hcl)
> summary(pmodel)
Data: X dimension: 16 2048
Y dimension: 16 1
Fit method: svdpc
Number of components considered: 15
TRAINING: % variance explained
1 comps 2 comps 3 comps 4 comps 5 comps 6 comps
X 85.7 96.91 99.29 99.64 99.81 99.92
concentration.hcl 45.4 90.14 98.35 98.72 98.73 99.27
...
Unfortunately, I am not seeing anything in my loadings:
> pmodel$loadings
... (truncated)
3291.07
3291.68
3292.29
3292.89
3293.49
3294.1
3294.7
3295.3
3295.9
3296.5
3297.09
3297.69
3298.29
3298.88
3299.48
3300.07
3300.66
3301.26
3301.85
3302.44
3303.03
3303.62
3304.2
3304.79
3305.38
3305.96
3306.55
3307.14
Comp 1 Comp 2 Comp 3 Comp 4 Comp 5 Comp 6 Comp 7 Comp 8 Comp 9
SS loadings 1 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
Proportion Var 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
Cumulative Var 0 0.001 0.001 0.002 0.002 0.003 0.003 0.004 0.004
Comp 10 Comp 11 Comp 12 Comp 13 Comp 14 Comp 15
SS loadings 1.000 1.000 1.000 1.000 1.000 1.000
Proportion Var 0.000 0.000 0.000 0.000 0.000 0.000
Cumulative Var 0.005 0.005 0.006 0.006 0.007 0.007
- Why can't I see my loadings?
- How can I find out which wavenumbers are contributing the most to the varying concentrations in my experiments?
NOTE: The data is available at https://gist.githubusercontent.com/anonymous/1d994685c3b3a5133b29/raw/696662a3aa199890958c162483c0cb7aa95e18ec/file1.txt
You just need to download this file and then type load('file1.txt')
and the variables will show up in your R environment