Determining chemical concentration with standard addition: An application of linear regression in JMP – A Guest Blog Post for the JMP Blog

I am very excited to announce that I have been invited by JMP to be a guest blogger for its official blog!  My thanks to Arati Mejdal, Global Social Media Manager for the JMP Division of SAS, for welcoming me into the JMP blogging community with so much support and encouragement, and I am pleased to publish my first post on the JMP Blog!  Mark Bailey and Byron Wingerd from JMP provided some valuable feedback to this blog post, and I am fortunate to get the chance to work with and learn from them!

Following the tradition of The Chemical Statistician, this post combines my passions for statistics and chemistry by illustrating how simple linear regression can be used for the method of standard addition in analytical chemistry.  In particular, I highlight the useful capability of the “Inverse Prediction” function under “Fit Model” platform in JMP to estimate the predictor given an observed response value (i.e. estimate the value of x_i given y_i).  Check it out!

JMP blog post - standard addition

Physical Chemistry Lesson of the Day – Effective Nuclear Charge

Much of chemistry concerns the interactions of the outermost electrons between different chemical species, whether they are atoms or molecules.  The properties of these outermost electrons depends in large part to the charge that the protons in the nucleus exerts on them.  Generally speaking, an atom with more protons exerts a larger positive charge.  However, with the exception of hydrogen, this positive charge is always less than the full nuclear charge.  This is due to the negative charge of the electrons in the inner shells, which partially offsets the positive charge from the nucleus.  Thus, the net charge that the nucleus exerts on the outermost electrons – the effective nuclear charge – is less than the charge that the nucleus would exert if there were no inner electrons between them.

Physical Chemistry Lesson of the Day – Standard Heats of Formation

The standard heat of formation, ΔHfº, of a chemical is the amount of heat absorbed or released from the formation of 1 mole of that chemical at 25 degrees Celsius and 1 bar from its elements in their standard states.  An element is in its standard state if it is in its most stable form and physical state (solid, liquid or gas) at 25 degrees Celsius and 1 bar.

For example, the standard heat of formation for carbon dioxide involves oxygen and carbon as the reactants.  Oxygen is most stable as O2 gas molecules, whereas carbon is most stable as solid graphite.  (Graphite is more stable than diamond under standard conditions.)

To phrase the definition in another way, the standard heat of formation is a special type of standard heat of reaction; the reaction is the formation of 1 mole of a chemical from its elements in their standard states under standard conditions.  The standard heat of formation is also called the standard enthalpy of formation (even though it really is a change in enthalpy).

By definition, the formation of an element from itself would yield no change in enthalpy, so the standard heat of reaction for all elements is zero.

 

Physical Chemistry Lesson of the Day – Hess’s Law

Hess’s law states that the change in enthalpy of a multi-stage chemical reaction is just the sum of the changes of enthalpy of the individual stages.  Thus, if a chemical reaction can be written as a sum of multiple intermediate reactions, then its change in enthalpy can be easily calculated.  This is especially helpful for a reaction whose change in enthalpy is difficult to measure experimentally.

Hess’s law is a consequence of the fact that enthalpy is a state function; the path between the reactants and the products is irrelevant to the change in enthalpy – only the initial and final values matter.  Thus, if there is a path for which the intermediate values of \Delta H are easy to obtain experimentally, then their sum equal the \Delta H for the overall reaction.

 

Physical Chemistry Lesson of the Day – The Perpetual Motion Machine

A thermochemical equation is a chemical equation that also shows the standard heat of reaction.  Recall that the value given by ΔHº is only true when the coefficients of the reactants and the products represent the number of moles of the corresponding substances.

The law of conservation of energy ensures that the standard heat of reaction for the reverse reaction of a thermochemical equation is just the forward reaction’s ΔHº multiplied by -1.  Let’s consider a thought experiment to show why this must be the case.

Imagine if a forward reaction is exothermic and has a ΔHº = -150 kJ, and its endothermic reverse reaction has a ΔHº = 100 kJ.  Then, by carrying out the exothermic forward reaction, 150 kJ is released from the reaction.  Out of that released heat, 100 kJ can be used to fuel the reverse reaction, and 50 kJ can be saved as a “profit” for doing something else, such as moving a machine.  This can be done perpetually, and energy can be created forever – of course, this has never been observed to happen, and the law of conservation of energy prevents such a perpetual motion machine from being made.  Thus, the standard heats of reaction for the forward and reverse reactions of the same thermochemical equation have the same magnitudes but opposite signs.

Regardless of how hard the reverse reaction may be to carry out, its ΔHº can still be written.

 

Physical Chemistry Lesson of the Day – Standard Heats of Reaction

The change in enthalpy of a chemical reaction indicates how much heat is absorbed or released by the system.  This is valuable information in chemistry, because the exchange in heat affects the reaction conditions and the surroundings, and that needs to be managed and taken into account – in theory, in the laboratory, in industry or in nature in general.

Chemists often want to compare the changes in enthalpy between different reactions.  Since changes in enthalpy depend on both temperature and pressure, we need to control for these 2 confounding variables by using a reference set of temperature and pressure.  This set of conditions is called the standard conditions, and it sets the standard temperature at 298 degrees Kelvin and the standard pressure at 1 bar.  (IUPAC changed the definition of standard pressure from 1 atmosphere to 1 bar in 1982.  The actual difference in pressure between these 2 definitions is very small.)

The standard enthalpy of reaction (or standard heat of reaction) is the change in enthalpy of a chemical reaction under standard conditions; the actual number of moles are specified by the coefficients of the balanced chemical equation.  (Since enthalpy is an extensive property, the same reaction under standard conditions could have different changes in enthalpy with different amounts of the reactants and products.  Thus, the number of moles of the reaction must be standardized somehow when defining the standard enthalpy of reaction.)  The standard enthalpy of reaction has the symbol ΔHº; the º symbol indicates the standard conditions.

Physical Chemistry Lesson of the Day – Intensive vs. Extensive Properties

An extensive property is a property that depends on the size of the system.  Examples include

An intensive property is a property that does not depend on the size of the system.  Examples include

As you can see, some intensive properties can be derived from extensive properties by dividing an extensive property by the mass, volume, or number of moles of the system.

Physical Chemistry Lesson of the Day – The Effect of Temperature on Changes in Internal Energy and Enthalpy

When the temperature of a system increases, the kinetic and potential energies of the atoms and molecules in the system increase.  Thus, the internal energy of the system increases, which means that the enthalpy of the system increases – this is true under constant pressure or constant volume.

Recall that the heat capacity of a system is the amount of energy that is required to raise the system’s temperature by 1 degree Kelvin.  Since the heat absorbed by the system in a thermodynamic process is the increase in enthalpy of the system, the heat capacity is just the change in enthalpy divided by the change in temperature.

C = \Delta H \div \Delta T.

Statistics and Chemistry Lesson of the Day – Illustrating Basic Concepts in Experimental Design with the Synthesis of Ammonia

To summarize what we have learned about experimental design in the past few Applied Statistics Lessons of the Day, let’s use an example from physical chemistry to illustrate these basic principles.

Ammonia (NH3) is widely used as a fertilizer in industry.  It is commonly synthesized by the Haber process, which involves a reaction between hydrogen gas and nitrogen gas.

N2 + 3 H2 → 2 NH3   (ΔH = −92.4 kJ·mol−1)

Recall that ΔH is the change in enthalpy.  Under constant pressure (which is the case for most chemical reactions), ΔH is the heat absorbed or released by the system.

Read more of this post

Physical Chemistry Lesson of the Day – The Difference Between Changes in Enthalpy and Changes Internal Energy

Let’s examine the difference between a change enthalpy and a change in internal energy.  It helps to think of the following 2 scenarios.

  • If the chemical reaction releases a gas but occurs at constant volume, then there is no pressure-volume work.  The only way for energy to be transferred between the system and the surroundings is through heat.  An example of a system under constant volume is a bomb calorimeter.  In this case,

\Delta H = \Delta U + P \Delta V = \Delta U + 0 = q - w + 0 = q - 0 + 0 = q

This heat is denoted as q_v to indicate that this is heat transferred under constant volume.  In this case, the change in enthalpy is the same as the change in internal energy.

 

  • If the chemical reaction releases a gas and occurs at constant pressure, then energy can be transferred between the system and the surroundings through heat and/or work.  Thus,

\Delta H = \Delta U + P \Delta V = q - w + P \Delta V = q

This heat is denoted as q_p to indicate that this is heat transferred under constant pressure.  Thus, as the gas forms inside the cylinder, the piston pushes against the constant pressure that the atmosphere exerts on it.  The total energy released by the chemical reaction allows some energy to be used for the pressure-volume work, with the remaining energy being released via heat.  (Recall that these are the 2 ways for internal energy to be changed according to the First Law of Thermodynamics.)  Thus, the difference between enthalpy and internal energy arises under constant pressure – the difference is the pressure-volume work.

Reactions under constant pressure are often illustrated by a reaction that releases a gas in cylinder with a movable piston, but they are actually quite common.  In fact, in chemistry, reactions under constant pressure are much more common than reactions under constant volume.  Chemical reactions often happen in beakers, flasks or any container open to the constant pressure of the atmosphere.

Physical Chemistry Lesson of the Day – Heat Capacity

The heat capacity of a system is the amount of heat required to increase the temperature of the system by 1 degree.  Heat is measured in joules (J) in the SI system, and heat capacity is dependent on each substance.  To make heat capacities comparable between substances, molar heat capacity or specific heat capacity are often used.

  • Molar heat capacity is the amount of heat required to increase the temperature of 1 mole of a substance by 1 degree.
  • Specific heat capacity is the amount of heat required to increase the temperature of 1 gram of a substance by 1 degree.

For example, over the range 0 to 100 degrees Celsius (or 273.15 to 373.15 degrees Kelvin), 4.18 J of heat on average is required to increase the temperature of 1 gram of water by 1 degree Kelvin.  Thus, the average specific heat capacity of water in that temperature range is 4.18 J/(g·K).

Physical Chemistry Lesson of the Day: Pressure-Volume Work

In chemistry, a common type of work is the expansion or compression of a gas under constant pressure.  Recall from physics that pressure is defined as force applied per unit of area.

P = F \div A

P \times A = F

Consider a chemical reaction that releases a gas as its product inside a sealed cylinder with a movable piston.

 

Gax_expanding_doing_work_on_a_piston_in_a_cylinder

Image from Dpumroy via Wikimedia.

As the gas expands inside the cylinder, it pushes against the piston, and work is done by the system against the surroundings.  The atmospheric pressure on the cylinder remains constant while the cylinder expands, and the volume of the cylinder increases as a result.  The volume of the cylinder at any given point is the area of the piston times the length of the cylinder.  The change in volume is equal to the area of the piston times the distance along which the piston was pushed by the expanding gas.

w = -P \times \Delta V

w = -P \times A \times \Delta L

w = -F \times \Delta L

Note that this last line is just the definition of work under constant force in the same direction as the displacement, multiplied by the negative sign to follow the sign convention in chemistry.

Physical Chemistry Lesson of the Day – The First Law of Thermodynamics

The change in internal energy of a system is defined to be the internal energy of a system in its final state subtracted by the internal energy of the system in its initial state.

\Delta U = U_{final} - U_{initial}.

However, since we cannot measure the internal energy of a system directly at any point in time, how can we calculate the change in internal energy?

The First Law of Thermodynamics states that any change in the internal energy of a system is equal to the heat absorbed the system plus any work done on the system.  Mathematically,

\Delta U = q + w.

Recall that I am using the sign convention in chemistry.

The value of q and w can be positive or negative.

  • A negative q denotes heat released by the system.
  • A negative w denotes work done by the system.

Physical Chemistry Lesson of the Day – Basic Terminology in Thermodynamics

A system is the part of the universe of interest, and the surroundings is everything else in the universe.

The internal energy of a system is the sum of the kinetic and potential energies of all of the particles (atoms and molecules) in the system.  This cannot be measured, but changes in internal energy can be measured.

There are 2 ways in which the internal energy of a system can change: heat and work.

  • Heat is the transfer of energy between 2 objects due to a temperature difference.  In chemistry, heat is commonly observed when a chemical reaction absorbs or releases energy.
  • Work is force acting over a distance.  In chemistry, a common type of work is the expansion or compression of a gas.

In chemistry, it is conventional to take the system’s point of view in deciding the sign of heat and work.  Thus, if heat is entering the system or if work is done on the system, then the sign is positive.  If heat is exiting the system of if work is done by the system, then the sign is negative.

When Does the Kinetic Theory of Gases Fail? Examining its Postulates with Assistance from Simple Linear Regression in R

Introduction

The Ideal Gas Law, \text{PV} = \text{nRT} , is a very simple yet useful relationship that describes the behaviours of many gases pretty well in many situations.  It is “Ideal” because it makes some assumptions about gas particles that make the math and the physics easy to work with; in fact, the simplicity that arises from these assumptions allows the Ideal Gas Law to be easily derived from the kinetic theory of gases.  However, there are situations in which those assumptions are not valid, and, hence, the Ideal Gas Law fails.

Boyle’s law is inherently a part of the Ideal Gas Law.  It states that, at a given temperature, the pressure of an ideal gas is inversely proportional to its volume.  Equivalently, it states the product of the pressure and the volume of an ideal gas is a constant at a given temperature.

\text{P} \propto \text{V}^{-1}

An Example of The Failure of the Ideal Gas Law

This law is valid for many gases in many situations, but consider the following data on the pressure and volume of 1.000 g of oxygen at 0 degrees Celsius.  I found this data set in Chapter 5.2 of “General Chemistry” by Darrell Ebbing and Steven Gammon.

               Pressure (atm)      Volume (L)              Pressure X Volume (atm*L)
[1,]           0.25                2.8010                  0.700250
[2,]           0.50                1.4000                  0.700000
[3,]           0.75                0.9333                  0.699975
[4,]           1.00                0.6998                  0.699800
[5,]           2.00                0.3495                  0.699000
[6,]           3.00                0.2328                  0.698400
[7,]           4.00                0.1744                  0.697600
[8,]           5.00                0.1394                  0.697000

The right-most column is the product of pressure and temperature, and it is not constant.  However, are the differences between these values significant, or could it be due to some random variation (perhaps round-off error)?

Here is the scatter plot of the pressure-volume product with respect to pressure.

scatter plot pv vs pressure

These points don’t look like they are on a horizontal line!  Let’s analyze these data using normal linear least-squares regression in R.

Read more of this post

How to Calculate a Partial Correlation Coefficient in R: An Example with Oxidizing Ammonia to Make Nitric Acid

Introduction

Today, I will talk about the math behind calculating partial correlation and illustrate the computation in R.  The computation uses an example involving the oxidation of ammonia to make nitric acid, and this example comes from a built-in data set in R called stackloss.

I read Pages 234-237 in Section 6.6 of “Discovering Statistics Using R” by Andy Field, Jeremy Miles, and Zoe Field to learn about partial correlation.  They used a data set called “Exam Anxiety.dat” available from their companion web site (look under “6 Correlation”) to illustrate this concept; they calculated the partial correlation coefficient between exam anxiety and revision time while controlling for exam score.  As I discuss further below, the plot between the 2 above residuals helps to illustrate the calculation of partial correlation coefficients.  This plot makes intuitive sense; if you take more time to study for an exam, you tend to have less exam anxiety, so there is a negative correlation between revision time and exam anxiety.

residuals plot anxiety and revision time controlling exam score

They used a function called pcor() in a package called “ggm”; however, I suspect that this package is no longer working properly, because it depends on a deprecated package called “RBGL” (i.e. “RBGL” is no longer available in CRAN).  See this discussion thread for further information.  Thus, I wrote my own R function to illustrate partial correlation.

Partial correlation is the correlation between 2 random variables while holding other variables constant.  To calculate the partial correlation between X and Y while holding Z constant (or controlling for the effect of Z, or averaging out Z),

Read more of this post

How do Dew and Fog Form? Nature at Work with Temperature, Vapour Pressure, and Partial Pressure

In the early morning, especially here in Canada, I often see dew – water droplets formed by the condensation of water vapour on outside surfaces, like windows, car roofs, and leaves of trees.  I also sometimes see fog – water droplets or ice crystals that are suspended in air and often blocking visibility at great distances.  Have you ever wondered how they form?  It turns out that partial pressure, vapour pressure and temperature are the key phenomena at work.

dew fog

Dew (by Staffan Enbom) and Fog (by Jon Zander)

Source: Wikimedia

Read more of this post

Discovering Argon with the 2-Sample t-Test

I learned about Lord Rayleigh’s discovery of argon in my 2nd-year analytical chemistry class while reading “Quantitative Chemical Analysis” by Daniel Harris.  (William Ramsay was also responsible for this discovery.)  This is one of my favourite stories in chemistry; it illustrates how diligence in measurement can lead to an elegant and surprising discovery.  I find no evidence that Rayleigh and Ramsay used statistics to confirm their findings; their paper was published 13 years before Gosset published about the t-test.  Thus, I will use a 2-sample t-test in R to confirm their result.

Lord Rayleigh                                    William Ramsay

Photos of Lord Rayleigh and William Ramsay

Source: Wikimedia Commons

Read more of this post

Why Does Diabetes Cause Excessive Urination and Thirst? A Lesson on Osmosis

A TABA Seminar on Diabetes

I have the pleasure of being an executive member of the Toronto Applied Biostatistics Association (TABA), a volunteer-run professional organization here in Toronto that organizes seminars on biostatistics.  During this past Tuesday, Dr. Loren Grossman from the LMC Diabetes and Endocrinology Centre generously donated his time to deliver an introductory seminar on diabetes for biostatisticians.  The Institute for Clinical and Evaluative Sciences (ICES) at Sunnybrook Hospital kindly hosted us and provided the venue for the seminar.  As a chemist and a former pre-medical student who studied physiology, I really enjoyed this intellectual treat, especially since Loren was clear, informative, and very knowledgeable about the subject.

blue circle

The blue circle is a global symbol for diabetes.

Source: Wikimedia Commons

Read more of this post

The Gold Foil Experiment and The 250-Million-Ton Pea: The Composition of the Atom

This Atom Is Not To Scale

In a recent post about isotopic abundance, I used a prototypical image of a lithium atom to illustrate the basic structure of an atom.  However, the image was deliberately not drawn to scale to make the protons, neutrons, and electrons visible.  Let’s look at the basic composition of the atom to see why, and we owe this understanding to Ernest Rutherford.  First, let’s give some historical background about what motivated Rutherford to conduct this experiment; we first turn to the Plum Pudding Model by J.J. Thomson.

The Plum Pudding Model

Before 1911, the dominant theory of atomic composition was J.J. Thomson‘s “plum pudding” model.  Thomson hypothesized that an atom consisted of electrons as negatively charged particles (the “plums”) “floating” in a “pudding” of positive charge.

plum pudding model

Plum Pudding Model of the Atom

Source: Wikimedia Commons

Read more of this post

Follow

Get every new post delivered to your Inbox.

Join 343 other followers